Regression (Phase-based) SUPER CLEAN

Init

Set Working Directory

Imports

Input and Output Directories and Files

Check Period and Phase in df2

Check Period and Phase in df3

Prepare for Regression

Code
ofd4 <- file.path(ofd0, "n0001-models-phase-i0021-all")
dir.create(ofd4, showWarnings = FALSE, recursive = TRUE)

model <- "fit0x0"
fbase <- file.path(ofd4, model)
fpath <- paste0(fbase, ".extension")
cat0(fpath)
./data/20240428T200156-politicians-aux-analysis/n0001-init//n0001-models-phase-i0021-all/fit0x0.extension 

Fitting and Marginalization

Cleanup

Save Data for Reference

Source Helpers

Code
source("./helpers/helpers0.R")
source("./helpers/helpers2.R")

Model fit01aPh: Null

Fit

Code
model <- "fit01aPh"
suppressWarnings(rm(list = model))
assign(
  model,
  lmerTest::lmer(
    formula = Agency ~ (1 | Name) + 1,
    data = df0,
    REML = REML,
    control = control))

fbase <- get_model_info(model, ofd4)
fit01aPh: [df0] Agency ~ (1 | Name) + 1
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: Agency ~ (1 | Name) + 1
   Data: df0
Control: control

REML criterion at convergence: 26631.7

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-7.9514 -0.5639 -0.0023  0.5683  7.3986 

Random effects:
 Groups   Name        Variance Std.Dev.
 Name     (Intercept) 0.006209 0.0788  
 Residual             0.067519 0.2598  
Number of obs: 169997, groups:  Name, 870

Fixed effects:
             Estimate Std. Error        df t value Pr(>|t|)    
(Intercept) 4.986e-01  2.807e-03 8.264e+02   177.7   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------------------------------- 
fit01aPh: [df0] Agency ~ (1 | Name) + 1
# R2 for Mixed Models

  Conditional R2: 0.084
     Marginal R2: 0.000
--------------------------------------------------------------------- 
fit01aPh: [df0] Agency ~ (1 | Name) + 1
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.084
  Unadjusted ICC: 0.084
--------------------------------------------------------------------- 
fit01aPh: [df0] Agency ~ (1 | Name) + 1
# ICC by Group

Group |   ICC
-------------
Name  | 0.084
--------------------------------------------------------------------- 

Efects: Random

Code
model <- "fit01aPh"
extra <- "9001"
terms <- NULL

suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- sjPlot::plot_model(get(model), type="re")

fbasefig <- file.path(ofd4, paste0(model, "-xtr-", extra, "-random", paste(terms, collapse = "-x-")))

ggsave(file=paste0(fbasefig,".png"),plot=gg88,width=8,height=88,limitsize=FALSE)
ggsave(file=paste0(fbasefig,".svg"),plot=gg88,width=8,height=88,limitsize=FALSE)
## knitr::opts_chunk$set(fig.width=unit(8,"cm"), fig.height=unit(88,"cm"))
gg88

Model fit02aPh: Time

Fit

Code
model <- "fit02aPh"
suppressWarnings(rm(list = model))
assign(
  model,
  lmerTest::lmer(
    formula = Agency ~ (Time | Name) + Time,
    data = df0,
    REML = REML,
    control = control))

fbase <- get_model_info(model, ofd4)
fit02aPh: [df0] Agency ~ (Time | Name) + Time
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: Agency ~ (Time | Name) + Time
   Data: df0
Control: control

REML criterion at convergence: 24941.9

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-8.0353 -0.5639 -0.0047  0.5664  7.3362 

Random effects:
 Groups   Name        Variance Std.Dev. Corr
 Name     (Intercept) 0.006283 0.07927      
          Time        0.004088 0.06394  0.18
 Residual             0.066384 0.25765      
Number of obs: 169997, groups:  Name, 870

Fixed effects:
              Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)   0.498029   0.002848 816.443563 174.884  < 2e-16 ***
Time         -0.010230   0.002634 709.116999  -3.884 0.000112 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------------------------------- 
fit02aPh: [df0] Agency ~ (Time | Name) + Time
# R2 for Mixed Models

  Conditional R2: 0.102
     Marginal R2: 0.000
--------------------------------------------------------------------- 
fit02aPh: [df0] Agency ~ (Time | Name) + Time
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.102
  Unadjusted ICC: 0.102
--------------------------------------------------------------------- 
fit02aPh: [df0] Agency ~ (Time | Name) + Time
Model contains random slopes. Cannot compute accurate ICCs by group
  factors.
# ICC by Group

Group |   ICC
-------------
Name  | 0.085
--------------------------------------------------------------------- 

Effects: Time

Compute

Code
model <- "fit02aPh"
extra <- "1001"
terms <- c("Time")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
fit02aPh: [df0] Agency ~ (Time | Name) + Time
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted values of Agency

 Time | Predicted |     95% CI
------------------------------
-1.00 |      0.51 | 0.50, 0.51
-0.50 |      0.50 | 0.50, 0.51
 0.00 |      0.50 | 0.49, 0.50
 0.50 |      0.50 | 0.49, 0.50
 1.00 |      0.49 | 0.48, 0.50
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Time

Slope     |       95% CI |     p
--------------------------------
-7.57e-03 | -0.01,  0.00 | 0.004
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Time

Slope     |       95% CI |     p
--------------------------------
-7.57e-03 | -0.01,  0.00 | 0.004

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + timeD + lineE + lineT + lineR + rect5 + cogsys::theme0 ## + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Model fit03aPh: Time x Phase

Fit

Code
model <- "fit03aPh"
suppressWarnings(rm(list = model))
assign(
  model,
  lmerTest::lmer(
    formula = Agency ~ (Time | Name) + Time * Phase,
    data = df0,
    REML = REML,
    control = control))

fbase <- get_model_info(model, ofd4)
fit03aPh: [df0] Agency ~ (Time | Name) + Time * Phase
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: Agency ~ (Time | Name) + Time * Phase
   Data: df0
Control: control

REML criterion at convergence: 24043.7

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-8.1156 -0.5629 -0.0072  0.5649  7.3761 

Random effects:
 Groups   Name        Variance Std.Dev. Corr
 Name     (Intercept) 0.006224 0.07889      
          Time        0.004129 0.06425  0.18
 Residual             0.066017 0.25694      
Number of obs: 169997, groups:  Name, 870

Fixed effects:
               Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)   5.285e-01  3.170e-03  1.284e+03 166.749   <2e-16 ***
Time          4.459e-02  3.657e-03  2.769e+03  12.192   <2e-16 ***
PhaseAE      -4.145e-03  4.178e-03  1.691e+05  -0.992   0.3212    
PhaseBR      -5.689e-01  3.066e-02  1.686e+05 -18.558   <2e-16 ***
PhaseAR      -9.121e-03  4.936e-03  1.697e+05  -1.848   0.0646 .  
Time:PhaseAE -3.579e-01  2.590e-02  1.688e+05 -13.820   <2e-16 ***
Time:PhaseBR  1.610e+00  9.670e-02  1.686e+05  16.650   <2e-16 ***
Time:PhaseAR -9.963e-02  7.213e-03  1.676e+05 -13.812   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------------------------------- 
fit03aPh: [df0] Agency ~ (Time | Name) + Time * Phase
# R2 for Mixed Models

  Conditional R2: 0.107
     Marginal R2: 0.006
--------------------------------------------------------------------- 
fit03aPh: [df0] Agency ~ (Time | Name) + Time * Phase
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.102
  Unadjusted ICC: 0.101
--------------------------------------------------------------------- 
fit03aPh: [df0] Agency ~ (Time | Name) + Time * Phase
Model contains random slopes. Cannot compute accurate ICCs by group
  factors.
# ICC by Group

Group |   ICC
-------------
Name  | 0.085
--------------------------------------------------------------------- 

Effects: Time

Compute

Code
model <- "fit03aPh"
extra <- "1001"
terms <- c("Time")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
fit03aPh: [df0] Agency ~ (Time | Name) + Time * Phase
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted values of Agency

 Time | Predicted |     95% CI
------------------------------
-1.00 |      0.45 | 0.44, 0.47
-0.50 |      0.48 | 0.47, 0.49
 0.00 |      0.50 | 0.50, 0.51
 0.50 |      0.53 | 0.52, 0.54
 1.00 |      0.56 | 0.54, 0.57
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Time

Slope |     95% CI |      p
---------------------------
0.05  | 0.04, 0.06 | < .001
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Time

Slope |     95% CI |      p
---------------------------
0.05  | 0.04, 0.06 | < .001

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 + timeD + lineE + lineT + lineR + rect3 ## + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Phase

Compute

Code
model <- "fit03aPh"
extra <- "1002"
terms <- c("Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
fit03aPh: [df0] Agency ~ (Time | Name) + Time * Phase
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted values of Agency

Phase | Predicted |       95% CI
--------------------------------
BE    |      0.53 |  0.52,  0.53
AE    |      0.55 |  0.54,  0.56
BR    |     -0.15 | -0.22, -0.08
AR    |      0.53 |  0.51,  0.54
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
Phase | Predicted |       95% CI |      p
-----------------------------------------
BE    |      0.53 |  0.52,  0.53 | < .001
AE    |      0.55 |  0.54,  0.56 | < .001
BR    |     -0.15 | -0.22, -0.08 | < .001
AR    |      0.53 |  0.51,  0.54 | < .001
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# Pairwise comparisons

Phase | Contrast |       95% CI |      p
----------------------------------------
BE-AE |    -0.02 | -0.03, -0.01 | < .001
BE-BR |     0.68 |  0.61,  0.75 | < .001
BE-AR | 2.34e-03 | -0.01,  0.01 | 0.658 
AE-BR |     0.70 |  0.63,  0.77 | < .001
AE-AR |     0.02 |  0.01,  0.04 | 0.003 
BR-AR |    -0.68 | -0.75, -0.60 | < .001

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect4 ## + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Time x Phase

Compute

Code
model <- "fit03aPh"
extra <- "1003"
terms <- c("Time","Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
fit03aPh: [df0] Agency ~ (Time | Name) + Time * Phase
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted values of Agency

Phase: BE

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.48 | 0.47,  0.49
-0.50 |      0.51 | 0.50,  0.51
 0.00 |      0.53 | 0.52,  0.54
 0.50 |      0.56 | 0.55,  0.56
 1.00 |      0.58 | 0.57,  0.59

Phase: AE

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.84 | 0.78,  0.89
-0.50 |      0.68 | 0.65,  0.71
 0.00 |      0.53 | 0.52,  0.54
 0.50 |      0.37 | 0.35,  0.39
 1.00 |      0.22 | 0.17,  0.26

Phase: BR

 Time | Predicted |       95% CI
--------------------------------
-1.00 |     -1.70 | -1.95, -1.45
-0.50 |     -0.87 | -1.02, -0.71
 0.00 |     -0.04 | -0.10,  0.02
 0.50 |      0.79 |  0.76,  0.83
 1.00 |      1.62 |  1.49,  1.75

Phase: AR

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.57 | 0.55,  0.60
-0.50 |      0.55 | 0.53,  0.56
 0.00 |      0.52 | 0.51,  0.53
 0.50 |      0.50 | 0.49,  0.50
 1.00 |      0.47 | 0.46,  0.48
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Time

Phase | Slope |       95% CI |      p
-------------------------------------
BE    |  0.04 |  0.04,  0.05 | < .001
AE    | -0.31 | -0.36, -0.26 | < .001
BR    |  1.65 |  1.47,  1.84 | < .001
AR    | -0.06 | -0.07, -0.04 | < .001
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Time

Phase | Contrast |       95% CI |      p
----------------------------------------
BE-AE |     0.36 |  0.31,  0.41 | < .001
BE-BR |    -1.61 | -1.80, -1.42 | < .001
BE-AR |     0.10 |  0.09,  0.11 | < .001
AE-BR |    -1.97 | -2.16, -1.77 | < .001
AE-AR |    -0.26 | -0.31, -0.21 | < .001
BR-AR |     1.71 |  1.52,  1.90 | < .001

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 + timeD + lineE + lineT + lineR + rect3 + scaleA
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Code
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Model fit04aPh: Time x Phase x Outcome

Fit

Code
model <- "fit04aPh"
suppressWarnings(rm(list = model))
assign(
  model,
  lmerTest::lmer(
    formula = Agency ~ (Time | Name) + Time * Phase * Outcome,
    data = df0,
    REML = REML,
    control = control))

fbase <- get_model_info(model, ofd4)
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: Agency ~ (Time | Name) + Time * Phase * Outcome
   Data: df0
Control: control

REML criterion at convergence: 23540

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-8.1902 -0.5632 -0.0074  0.5639  7.3864 

Random effects:
 Groups   Name        Variance Std.Dev. Corr 
 Name     (Intercept) 0.004798 0.06927       
          Time        0.003348 0.05786  -0.07
 Residual             0.065916 0.25674       
Number of obs: 169997, groups:  Name, 870

Fixed effects:
                             Estimate Std. Error         df t value Pr(>|t|)
(Intercept)                 5.151e-01  4.450e-03  1.471e+03 115.767  < 2e-16
Time                        5.703e-02  5.597e-03  3.426e+03  10.189  < 2e-16
PhaseAE                    -4.245e-02  7.688e-03  1.693e+05  -5.521 3.38e-08
PhaseBR                    -4.966e-01  6.025e-02  1.690e+05  -8.242  < 2e-16
PhaseAR                    -1.195e-01  1.034e-02  1.662e+05 -11.561  < 2e-16
Outcomewinner               2.383e-02  5.853e-03  1.425e+03   4.072 4.92e-05
Time:PhaseAE               -4.906e-01  5.053e-02  1.692e+05  -9.710  < 2e-16
Time:PhaseBR                1.152e+00  1.903e-01  1.689e+05   6.052 1.44e-09
Time:PhaseAR               -5.823e-02  1.523e-02  1.543e+05  -3.824 0.000131
Time:Outcomewinner         -2.039e-02  7.198e-03  3.276e+03  -2.833 0.004646
PhaseAE:Outcomewinner       5.796e-02  9.165e-03  1.692e+05   6.324 2.56e-10
PhaseBR:Outcomewinner      -9.406e-02  6.997e-02  1.689e+05  -1.344 0.178864
PhaseAR:Outcomewinner       1.478e-01  1.178e-02  1.679e+05  12.550  < 2e-16
Time:PhaseAE:Outcomewinner  1.675e-01  5.885e-02  1.692e+05   2.846 0.004424
Time:PhaseBR:Outcomewinner  6.256e-01  2.209e-01  1.688e+05   2.832 0.004623
Time:PhaseAR:Outcomewinner -4.478e-02  1.731e-02  1.602e+05  -2.586 0.009706
                              
(Intercept)                ***
Time                       ***
PhaseAE                    ***
PhaseBR                    ***
PhaseAR                    ***
Outcomewinner              ***
Time:PhaseAE               ***
Time:PhaseBR               ***
Time:PhaseAR               ***
Time:Outcomewinner         ** 
PhaseAE:Outcomewinner      ***
PhaseBR:Outcomewinner         
PhaseAR:Outcomewinner      ***
Time:PhaseAE:Outcomewinner ** 
Time:PhaseBR:Outcomewinner ** 
Time:PhaseAR:Outcomewinner ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------------------------------- 
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
# R2 for Mixed Models

  Conditional R2: 0.102
     Marginal R2: 0.021
--------------------------------------------------------------------- 
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.083
  Unadjusted ICC: 0.081
--------------------------------------------------------------------- 
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
Model contains random slopes. Cannot compute accurate ICCs by group
  factors.
# ICC by Group

Group |   ICC
-------------
Name  | 0.067
--------------------------------------------------------------------- 

Parameters

Code
pp(model);
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
Code
parameters::model_parameters(get(model))
# Fixed Effects

Parameter                              | Coefficient |       SE |         95% CI | t(169977) |      p
-----------------------------------------------------------------------------------------------------
(Intercept)                            |        0.52 | 4.45e-03 | [ 0.51,  0.52] |    115.77 | < .001
Time                                   |        0.06 | 5.60e-03 | [ 0.05,  0.07] |     10.19 | < .001
Phase [AE]                             |       -0.04 | 7.69e-03 | [-0.06, -0.03] |     -5.52 | < .001
Phase [BR]                             |       -0.50 |     0.06 | [-0.61, -0.38] |     -8.24 | < .001
Phase [AR]                             |       -0.12 |     0.01 | [-0.14, -0.10] |    -11.56 | < .001
Outcome [winner]                       |        0.02 | 5.85e-03 | [ 0.01,  0.04] |      4.07 | < .001
Time × Phase [AE]                      |       -0.49 |     0.05 | [-0.59, -0.39] |     -9.71 | < .001
Time × Phase [BR]                      |        1.15 |     0.19 | [ 0.78,  1.52] |      6.05 | < .001
Time × Phase [AR]                      |       -0.06 |     0.02 | [-0.09, -0.03] |     -3.82 | < .001
Time × Outcome [winner]                |       -0.02 | 7.20e-03 | [-0.03, -0.01] |     -2.83 | 0.005 
Phase [AE] × Outcome [winner]          |        0.06 | 9.17e-03 | [ 0.04,  0.08] |      6.32 | < .001
Phase [BR] × Outcome [winner]          |       -0.09 |     0.07 | [-0.23,  0.04] |     -1.34 | 0.179 
Phase [AR] × Outcome [winner]          |        0.15 |     0.01 | [ 0.12,  0.17] |     12.55 | < .001
(Time × Phase [AE]) × Outcome [winner] |        0.17 |     0.06 | [ 0.05,  0.28] |      2.85 | 0.004 
(Time × Phase [BR]) × Outcome [winner] |        0.63 |     0.22 | [ 0.19,  1.06] |      2.83 | 0.005 
(Time × Phase [AR]) × Outcome [winner] |       -0.04 |     0.02 | [-0.08, -0.01] |     -2.59 | 0.010 

# Random Effects

Parameter                  | Coefficient
----------------------------------------
SD (Intercept: Name)       |        0.07
SD (Time: Name)            |        0.06
Cor (Intercept~Time: Name) |       -0.07
SD (Residual)              |        0.26

Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
  using a Wald t-distribution approximation.

Summary

Code
pp(model);
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
Code
tbl0 <- gtsummary::tbl_regression(
  get(model),
  add_pairwise_contrasts = TRUE,
  exponentiate = FALSE,
  tidy_fun = broom.mixed::tidy,
)
Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
To enable adjustments, add the argument 'pbkrtest.limit = 169997' (or larger)
[or, globally, 'set emm_options(pbkrtest.limit = 169997)' or larger];
but be warned that this may result in large computation time and memory use.
Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
To enable adjustments, add the argument 'lmerTest.limit = 169997' (or larger)
[or, globally, 'set emm_options(lmerTest.limit = 169997)' or larger];
but be warned that this may result in large computation time and memory use.
NOTE: Results may be misleading due to involvement in interactions
Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
To enable adjustments, add the argument 'pbkrtest.limit = 169997' (or larger)
[or, globally, 'set emm_options(pbkrtest.limit = 169997)' or larger];
but be warned that this may result in large computation time and memory use.
Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
To enable adjustments, add the argument 'lmerTest.limit = 169997' (or larger)
[or, globally, 'set emm_options(lmerTest.limit = 169997)' or larger];
but be warned that this may result in large computation time and memory use.
NOTE: Results may be misleading due to involvement in interactions
Code
tbl0
Characteristic Beta 95% CI1 p-value
Time 0.06 0.05, 0.07 <0.001
Phase


    AE - BE 0.01 0.00, 0.03 0.10
    BR - BE -0.64 -0.75, -0.53 <0.001
    BR - AE -0.66 -0.77, -0.55 <0.001
    AR - BE -0.04 -0.06, -0.02 <0.001
    AR - AE -0.05 -0.08, -0.03 <0.001
    AR - BR 0.60 0.49, 0.71 <0.001
Outcome


    winner - loser 0.04 0.00, 0.08 0.069
Time * Phase


    Time * AE -0.49 -0.59, -0.39 <0.001
    Time * BR 1.2 0.78, 1.5 <0.001
    Time * AR -0.06 -0.09, -0.03 <0.001
Time * Outcome


    Time * winner -0.02 -0.03, -0.01 0.005
Phase * Outcome


    AE * winner 0.06 0.04, 0.08 <0.001
    BR * winner -0.09 -0.23, 0.04 0.2
    AR * winner 0.15 0.12, 0.17 <0.001
Time * Phase * Outcome


    Time * AE * winner 0.17 0.05, 0.28 0.004
    Time * BR * winner 0.63 0.19, 1.1 0.005
    Time * AR * winner -0.04 -0.08, -0.01 0.010
Name.sd__(Intercept) 0.07

Name.cor__(Intercept).Time -0.07

Name.sd__Time 0.06

Residual.sd__Observation 0.26

1 CI = Confidence Interval

Effects: Time

Compute

Code
model <- "fit04aPh"
extra <- "1001"
terms <- c("Time")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted values of Agency

 Time | Predicted |     95% CI
------------------------------
-1.00 |      0.46 | 0.44, 0.47
-0.50 |      0.48 | 0.47, 0.49
 0.00 |      0.50 | 0.50, 0.51
 0.50 |      0.53 | 0.52, 0.54
 1.00 |      0.55 | 0.54, 0.56
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Time

Slope |     95% CI |      p
---------------------------
0.05  | 0.04, 0.06 | < .001
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Time

Slope |     95% CI |      p
---------------------------
0.05  | 0.04, 0.06 | < .001

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 + timeD + lineE + lineT + lineR + rect3 ## + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Phase

Compute

Code
model <- "fit04aPh"
extra <- "1002"
terms <- c("Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted values of Agency

Phase | Predicted |       95% CI
--------------------------------
BE    |      0.52 |  0.52,  0.53
AE    |      0.55 |  0.54,  0.57
BR    |     -0.12 | -0.19, -0.04
AR    |      0.51 |  0.50,  0.52
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
Phase | Predicted |       95% CI |      p
-----------------------------------------
BE    |      0.52 |  0.52,  0.53 | < .001
AE    |      0.55 |  0.54,  0.57 | < .001
BR    |     -0.12 | -0.19, -0.04 | 0.004 
AR    |      0.51 |  0.50,  0.52 | < .001
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# Pairwise comparisons

Phase | Contrast |       95% CI |      p
----------------------------------------
BE-AE |    -0.03 | -0.04, -0.02 | < .001
BE-BR |     0.64 |  0.56,  0.72 | < .001
BE-AR |     0.02 |  0.00,  0.03 | 0.007 
AE-BR |     0.67 |  0.59,  0.75 | < .001
AE-AR |     0.05 |  0.03,  0.06 | < .001
BR-AR |    -0.62 | -0.70, -0.55 | < .001

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect4 ## + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Time x Phase

Compute

Code
model <- "fit04aPh"
extra <- "1003"
terms <- c("Time","Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted values of Agency

Phase: BE

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.48 | 0.48,  0.49
-0.50 |      0.51 | 0.50,  0.51
 0.00 |      0.53 | 0.52,  0.53
 0.50 |      0.55 | 0.54,  0.56
 1.00 |      0.57 | 0.56,  0.58

Phase: AE

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.86 | 0.80,  0.92
-0.50 |      0.69 | 0.66,  0.72
 0.00 |      0.53 | 0.52,  0.53
 0.50 |      0.36 | 0.34,  0.38
 1.00 |      0.19 | 0.15,  0.24

Phase: BR

 Time | Predicted |       95% CI
--------------------------------
-1.00 |     -1.65 | -1.90, -1.40
-0.50 |     -0.84 | -1.00, -0.69
 0.00 |     -0.03 | -0.09,  0.03
 0.50 |      0.78 |  0.74,  0.81
 1.00 |      1.59 |  1.46,  1.72

Phase: AR

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.55 | 0.53,  0.58
-0.50 |      0.53 | 0.51,  0.55
 0.00 |      0.51 | 0.50,  0.52
 0.50 |      0.49 | 0.48,  0.49
 1.00 |      0.47 | 0.46,  0.47
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Time

Phase |     Slope |       95% CI |      p
-----------------------------------------
BE    |      0.06 |  0.05,  0.07 | < .001
AE    |     -0.43 | -0.53, -0.33 | < .001
BR    |      1.21 |  0.84,  1.58 | < .001
AR    | -1.19e-03 | -0.03,  0.03 | 0.936 
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Time

Phase | Contrast |       95% CI |      p
----------------------------------------
BE-AE |     0.49 |  0.39,  0.59 | < .001
BE-BR |    -1.15 | -1.52, -0.78 | < .001
BE-AR |     0.06 |  0.03,  0.09 | < .001
AE-BR |    -1.64 | -2.03, -1.26 | < .001
AE-AR |    -0.43 | -0.53, -0.33 | < .001
BR-AR |     1.21 |  0.84,  1.58 | < .001

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 + timeD + lineE + lineT + lineR + rect3 + scaleA
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Code
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Phase x Outcome

Compute

Code
model <- "fit04aPh"
extra <- "1004"
terms <- c("Phase","Outcome")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted values of Agency

Outcome: loser

Phase | Predicted |       95% CI
--------------------------------
BE    |      0.51 |  0.50,  0.52
AE    |      0.50 |  0.48,  0.52
BR    |     -0.07 | -0.21,  0.08
AR    |      0.39 |  0.37,  0.42

Outcome: winner

Phase | Predicted |       95% CI
--------------------------------
BE    |      0.53 |  0.53,  0.54
AE    |      0.57 |  0.56,  0.59
BR    |     -0.18 | -0.26, -0.09
AR    |      0.57 |  0.56,  0.58
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
Phase | Outcome | Predicted |       95% CI |      p
---------------------------------------------------
BE    |   loser |      0.51 |  0.50,  0.52 | < .001
AE    |   loser |      0.50 |  0.48,  0.52 | < .001
BR    |   loser |     -0.07 | -0.21,  0.08 | 0.364 
AR    |   loser |      0.39 |  0.37,  0.42 | < .001
BE    |  winner |      0.53 |  0.53,  0.54 | < .001
AE    |  winner |      0.57 |  0.56,  0.59 | < .001
BR    |  winner |     -0.18 | -0.26, -0.09 | < .001
AR    |  winner |      0.57 |  0.56,  0.58 | < .001
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# Pairwise comparisons

Phase |       Outcome | Contrast |       95% CI |      p
--------------------------------------------------------
BE-AE |   loser-loser | 9.06e-03 | -0.01,  0.03 | 0.404 
BE-BR |   loser-loser |     0.57 |  0.43,  0.72 | < .001
BE-AR |   loser-loser |     0.12 |  0.09,  0.14 | < .001
BE-BE |  loser-winner |    -0.03 | -0.04, -0.01 | < .001
BE-AE |  loser-winner |    -0.06 | -0.08, -0.05 | < .001
BE-BR |  loser-winner |     0.69 |  0.60,  0.77 | < .001
BE-AR |  loser-winner |    -0.06 | -0.08, -0.05 | < .001
AE-BR |   loser-loser |     0.57 |  0.42,  0.71 | < .001
AE-AR |   loser-loser |     0.11 |  0.08,  0.14 | < .001
AE-BE |  loser-winner |    -0.03 | -0.06, -0.01 | 0.003 
AE-AE |  loser-winner |    -0.07 | -0.10, -0.05 | < .001
AE-BR |  loser-winner |     0.68 |  0.59,  0.76 | < .001
AE-AR |  loser-winner |    -0.07 | -0.09, -0.04 | < .001
BR-AR |   loser-loser |    -0.46 | -0.60, -0.31 | < .001
BR-BE |  loser-winner |    -0.60 | -0.74, -0.46 | < .001
BR-AE |  loser-winner |    -0.64 | -0.78, -0.49 | < .001
BR-BR |  loser-winner |     0.11 | -0.06,  0.28 | 0.205 
BR-AR |  loser-winner |    -0.64 | -0.78, -0.49 | < .001
AR-BE |  loser-winner |    -0.14 | -0.16, -0.12 | < .001
AR-AE |  loser-winner |    -0.18 | -0.20, -0.15 | < .001
AR-BR |  loser-winner |     0.57 |  0.48,  0.66 | < .001
AR-AR |  loser-winner |    -0.18 | -0.20, -0.15 | < .001
BE-AE | winner-winner |    -0.04 | -0.05, -0.02 | < .001
BE-BR | winner-winner |     0.71 |  0.63,  0.80 | < .001
BE-AR | winner-winner |    -0.04 | -0.05, -0.02 | < .001
AE-BR | winner-winner |     0.75 |  0.66,  0.83 | < .001
AE-AR | winner-winner | 2.17e-03 | -0.01,  0.02 | 0.800 
BR-AR | winner-winner |    -0.75 | -0.83, -0.66 | < .001

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Time x Phase x Outcome

Compute

Code
model <- "fit04aPh"
extra <- "1005"
terms <- c("Time", "Outcome", "Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
fit04aPh: [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
Code
## test3 <- ggeffects::test_predictions(ggeff$pred0, test="pairwise", p_adjust="fdr", collapse_levels=TRUE)

cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted values of Agency

Outcome: loser
Phase: BE

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.45 | 0.44,  0.46
-0.50 |      0.48 | 0.47,  0.49
 0.00 |      0.51 | 0.50,  0.52
 0.50 |      0.54 | 0.53,  0.55
 1.00 |      0.57 | 0.56,  0.59

Outcome: loser
Phase: AE

 Time | Predicted |       95% CI
--------------------------------
-1.00 |      0.90 |  0.79,  1.01
-0.50 |      0.69 |  0.62,  0.75
 0.00 |      0.47 |  0.45,  0.49
 0.50 |      0.25 |  0.22,  0.29
 1.00 |      0.04 | -0.05,  0.13

Outcome: loser
Phase: BR

 Time | Predicted |       95% CI
--------------------------------
-1.00 |     -1.20 | -1.69, -0.70
-0.50 |     -0.59 | -0.89, -0.29
 0.00 |      0.02 | -0.10,  0.13
 0.50 |      0.62 |  0.55,  0.69
 1.00 |      1.23 |  0.97,  1.48

Outcome: loser
Phase: AR

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.39 | 0.34,  0.44
-0.50 |      0.39 | 0.36,  0.43
 0.00 |      0.39 | 0.37,  0.41
 0.50 |      0.39 | 0.38,  0.40
 1.00 |      0.39 | 0.38,  0.41

Outcome: winner
Phase: BE

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.50 | 0.49,  0.51
-0.50 |      0.52 | 0.51,  0.52
 0.00 |      0.54 | 0.53,  0.54
 0.50 |      0.56 | 0.55,  0.57
 1.00 |      0.58 | 0.56,  0.59

Outcome: winner
Phase: AE

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.84 | 0.77,  0.90
-0.50 |      0.69 | 0.66,  0.73
 0.00 |      0.55 | 0.54,  0.56
 0.50 |      0.41 | 0.39,  0.43
 1.00 |      0.27 | 0.22,  0.32

Outcome: winner
Phase: BR

 Time | Predicted |       95% CI
--------------------------------
-1.00 |     -1.87 | -2.16, -1.58
-0.50 |     -0.96 | -1.14, -0.78
 0.00 |     -0.05 | -0.12,  0.02
 0.50 |      0.85 |  0.81,  0.90
 1.00 |      1.76 |  1.61,  1.91

Outcome: winner
Phase: AR

 Time | Predicted |      95% CI
-------------------------------
-1.00 |      0.63 | 0.60,  0.65
-0.50 |      0.60 | 0.58,  0.62
 0.00 |      0.56 | 0.55,  0.58
 0.50 |      0.53 | 0.53,  0.54
 1.00 |      0.50 | 0.49,  0.51
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Time

Outcome | Phase |     Slope |       95% CI |      p
---------------------------------------------------
loser   |    BE |      0.06 |  0.05,  0.07 | < .001
loser   |    AE |     -0.43 | -0.53, -0.33 | < .001
loser   |    BR |      1.21 |  0.84,  1.58 | < .001
loser   |    AR | -1.19e-03 | -0.03,  0.03 | 0.936 
winner  |    BE |      0.04 |  0.03,  0.05 | < .001
winner  |    AE |     -0.29 | -0.35, -0.23 | < .001
winner  |    BR |      1.81 |  1.59,  2.03 | < .001
winner  |    AR |     -0.07 | -0.08, -0.05 | < .001
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Time

Outcome       | Phase | Contrast |       95% CI |      p
--------------------------------------------------------
loser-loser   | BE-AE |     0.49 |  0.39,  0.59 | < .001
loser-loser   | BE-BR |    -1.15 | -1.52, -0.78 | < .001
loser-loser   | BE-AR |     0.06 |  0.03,  0.09 | < .001
loser-winner  | BE-BE |     0.02 |  0.01,  0.03 | 0.005 
loser-winner  | BE-AE |     0.34 |  0.28,  0.40 | < .001
loser-winner  | BE-BR |    -1.76 | -1.98, -1.54 | < .001
loser-winner  | BE-AR |     0.12 |  0.10,  0.14 | < .001
loser-loser   | AE-BR |    -1.64 | -2.03, -1.26 | < .001
loser-loser   | AE-AR |    -0.43 | -0.53, -0.33 | < .001
loser-winner  | AE-BE |    -0.47 | -0.57, -0.37 | < .001
loser-winner  | AE-AE |    -0.15 | -0.26, -0.03 | 0.013 
loser-winner  | AE-BR |    -2.25 | -2.49, -2.01 | < .001
loser-winner  | AE-AR |    -0.37 | -0.47, -0.27 | < .001
loser-loser   | BR-AR |     1.21 |  0.84,  1.58 | < .001
loser-winner  | BR-BE |     1.17 |  0.80,  1.55 | < .001
loser-winner  | BR-AE |     1.50 |  1.12,  1.87 | < .001
loser-winner  | BR-BR |    -0.61 | -1.04, -0.17 | 0.007 
loser-winner  | BR-AR |     1.28 |  0.90,  1.65 | < .001
loser-winner  | AR-BE |    -0.04 | -0.07, -0.01 | 0.015 
loser-winner  | AR-AE |     0.29 |  0.22,  0.35 | < .001
loser-winner  | AR-BR |    -1.82 | -2.04, -1.59 | < .001
loser-winner  | AR-AR |     0.07 |  0.03,  0.10 | < .001
winner-winner | BE-AE |     0.32 |  0.26,  0.38 | < .001
winner-winner | BE-BR |    -1.78 | -2.00, -1.56 | < .001
winner-winner | BE-AR |     0.10 |  0.09,  0.12 | < .001
winner-winner | AE-BR |    -2.10 | -2.33, -1.87 | < .001
winner-winner | AE-AR |    -0.22 | -0.28, -0.16 | < .001
winner-winner | BR-AR |     1.88 |  1.66,  2.10 | < .001

Filter test table

Code
ggeff$test3 <- ggeffects::test_predictions(ggeff$pred0, test="pairwise", p_adjust="fdr", collapse_levels=TRUE)
## cat0(sep0)
## print(ggeff$test3, n = Inf)
ggeff$test4 <- ggeff$test3 %>% as_tibble() %>%
  dplyr::mutate(
    PhaseDashCount = str_count(Phase, fixed("-")),
    OutcomeDashCount = str_count(Outcome, fixed("-")),
    TotalDashCount = PhaseDashCount + OutcomeDashCount,
    ) %>%
  dplyr::filter(TotalDashCount==1) %>%
  dplyr::select(-TotalDashCount) %>%
  dplyr::arrange(PhaseDashCount, Outcome, Phase) %>%
  dplyr::select(-c(PhaseDashCount, OutcomeDashCount)) %>%
  identity()

print(ggeff$test4)
# A tibble: 16 × 7
   Time  Outcome      Phase Contrast conf.low conf.high  p.value
   <chr> <chr>        <chr>    <dbl>    <dbl>     <dbl>    <dbl>
 1 slope loser-winner AE     -0.147  -0.262     -0.0321 1.27e- 2
 2 slope loser-winner AR      0.0652  0.0321     0.0982 1.34e- 4
 3 slope loser-winner BE      0.0204  0.00628    0.0345 5.18e- 3
 4 slope loser-winner BR     -0.605  -1.04      -0.172  6.62e- 3
 5 slope loser        AE-AR  -0.432  -0.535     -0.330  2.45e-16
 6 slope loser        AE-BR  -1.64   -2.03      -1.26   1.47e-16
 7 slope loser        BE-AE   0.491   0.392      0.590  7.06e-22
 8 slope loser        BE-AR   0.0582  0.0284     0.0881 1.53e- 4
 9 slope loser        BE-BR  -1.15   -1.52      -0.779  1.82e- 9
10 slope loser        BR-AR   1.21    0.836      1.58   3.23e-10
11 slope winner       AE-AR  -0.220  -0.281     -0.160  1.55e-12
12 slope winner       AE-BR  -2.10   -2.33      -1.87   5.37e-72
13 slope winner       BE-AE   0.323   0.264      0.382  2.74e-26
14 slope winner       BE-AR   0.103   0.0869     0.119  2.74e-35
15 slope winner       BE-BR  -1.78   -2.00      -1.56   9.36e-56
16 slope winner       BR-AR   1.88    1.66       2.10   7.56e-62

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + timeD + lineE + lineT + lineR + rect0 + cogsys::theme0 + scaleA
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Code
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=24, height=72, limitsize = FALSE)

ggsave(file = paste0(ggeff$fbasefig, "-pred0-Fig.svg"), plot = gg88 + cogsys::theme2, width=24, height=96, limitsize = FALSE)

gg88

Plot: Nicer

Code
# knitr::opts_chunk$set(fig.width=unit(12,"cm"), fig.height=unit(18,"cm"))
# gg88
suppressWarnings(rm(list = ls(pattern = "^gg99")))
gg99 <- gg88 + cogsys::theme2 + scaleA
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Code
ggsave(file = paste0(ggeff$fbasefig, "-pred0-FIG.svg"), plot = gg99 + cogsys::theme2, width=24, height=96, limitsize = FALSE)

gg99

Save workspace

Code
save.image(file=file.path(ofd4, "session0.RData"))
## load(file.path(ofd4, "session0.RData"))
## load(file.path(ofd4, "session2.RData"))

Model fit04xPh: Time x Phase x Outcome

Prepare Data for the Re-scaled Model

Code
count8 = 15e3
count8 = 1e3

df8 <- df0 %>% 
  ## dplyr::group_by(Phase) %>%        ## CAUTION 
  ## dplyr::slice_sample(n=count8) %>% ## CAUTION 
  bruceR::grand_mean_center(
    vars=c("Agency", "Time"), 
    std=FALSE, 
    add.suffix="C") %>%
  identity()

contrasts(df8$Phase) <- contr.sum(levels(df8$Phase))
contrasts(df8$Outcome) <- contr.sum(levels(df8$Outcome))

contrasts(df8$Phase)
   [,1] [,2] [,3]
BE    1    0    0
AE    0    1    0
BR    0    0    1
AR   -1   -1   -1
Code
contrasts(df8$Outcome)
       [,1]
loser     1
winner   -1
Code
## attributes(df8$Phase)
## attributes(df8$Outcome)

Fit

Code
model <- "fit04xPh"
suppressWarnings(rm(list = model))
assign(
  model,
  lmerTest::lmer(
    ## formula = AgencyC ~ (TimeC | Name) + TimeC, ## CAUTION
    formula = AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome,
    data = df8,
    REML = REML,
    control = control))

fbase <- get_model_info(model, ofd4)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
   Data: df8
Control: control

REML criterion at convergence: 23562.2

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-8.1902 -0.5632 -0.0074  0.5639  7.3864 

Random effects:
 Groups   Name        Variance Std.Dev. Corr 
 Name     (Intercept) 0.004849 0.06963       
          TimeC       0.003347 0.05786  -0.12
 Residual             0.065916 0.25674       
Number of obs: 169997, groups:  Name, 870

Fixed effects:
                        Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)           -1.430e-01  1.111e-02  1.138e+05 -12.873  < 2e-16 ***
TimeC                  2.911e-01  2.871e-02  1.687e+05  10.141  < 2e-16 ***
Phase1                 1.673e-01  1.088e-02  1.689e+05  15.372  < 2e-16 ***
Phase2                 1.815e-01  1.164e-02  1.688e+05  15.591  < 2e-16 ***
Phase3                -4.760e-01  3.189e-02  1.689e+05 -14.925  < 2e-16 ***
Outcome1              -2.021e-02  1.111e-02  1.138e+05  -1.819  0.06893 .  
TimeC:Phase1          -2.443e-01  2.870e-02  1.689e+05  -8.510  < 2e-16 ***
TimeC:Phase2          -6.511e-01  3.535e-02  1.690e+05 -18.419  < 2e-16 ***
TimeC:Phase3           1.220e+00  8.317e-02  1.689e+05  14.671  < 2e-16 ***
TimeC:Outcome1        -8.335e-02  2.871e-02  1.687e+05  -2.904  0.00369 ** 
Phase1:Outcome1        7.600e-03  1.088e-02  1.689e+05   0.698  0.48496    
Phase2:Outcome1       -1.568e-02  1.164e-02  1.688e+05  -1.347  0.17804    
Phase3:Outcome1        7.591e-02  3.189e-02  1.689e+05   2.380  0.01730 *  
TimeC:Phase1:Outcome1  9.355e-02  2.870e-02  1.689e+05   3.259  0.00112 ** 
TimeC:Phase2:Outcome1  9.791e-03  3.535e-02  1.690e+05   0.277  0.78180    
TimeC:Phase3:Outcome1 -2.193e-01  8.317e-02  1.689e+05  -2.636  0.00838 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------------------------------- 
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
# R2 for Mixed Models

  Conditional R2: 0.102
     Marginal R2: 0.021
--------------------------------------------------------------------- 
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.083
  Unadjusted ICC: 0.081
--------------------------------------------------------------------- 
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Model contains random slopes. Cannot compute accurate ICCs by group
  factors.
# ICC by Group

Group |   ICC
-------------
Name  | 0.067
--------------------------------------------------------------------- 

Performance: Check Model (EXPERIMENTAL)

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
do_checks <- TRUE
do_checks <- FALSE

if (do_checks) {

  knitr::opts_chunk$set(fig.width=unit(8,"cm"), fig.height=unit(24,"cm"))

  suppressWarnings(rm(list = ls(pattern = "^check8")))
  check8 <- performance::check_model(get(model))

  suppressWarnings(rm(list = ls(pattern = "^gg88")))
  gg88 <- plot(check8)
  ## gg88
}

Save checks plot

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
if (do_checks) {
  model <- "fit04xPh"
  pp(model)

  knitr::opts_chunk$set(fig.width=unit(8,"cm"), fig.height=unit(24,"cm"))

  ggsave(
    file = file.path(ofd4, paste0("summary-check-model-", model, ".png")),
    plot = gg88,
    ## plot = last_plot(),
    width=8,
    height=24)
}

Performance: Check Collinearity

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
## performance::check_collinearity(get(model))

Performance: Check Convergence

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
performance::check_convergence(get(model))
[1] TRUE
attr(,"gradient")
[1] 4.648806e-06

Performance: Check Heteroscedasticity

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
performance::check_heteroscedasticity(get(model))
Warning: Heteroscedasticity (non-constant error variance) detected (p < .001).

Performance: Check Homogeneity

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
## performance::check_homogeneity(get(model))

Performance: Check Outliers

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
performance::check_outliers(get(model))
OK: No outliers detected.
- Based on the following method and threshold: cook (0.7).
- For variable: (Whole model)

Performance: Check Overdispersion

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
performance::check_overdispersion(get(model))
# Overdispersion test

 dispersion ratio = 0.992
          p-value = 0.152
No overdispersion detected.

Performance: Check Predictions

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
performance::check_predictions(get(model))
Warning: Minimum value of original data is not included in the
  replicated data.
  Model may not capture the variation of the data.Warning: Maximum value of original data is not included in the
  replicated data.
  Model may not capture the variation of the data.

Performance: Check Singularity

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
performance::check_singularity(get(model))
[1] FALSE

Performance: Check Zeroinflation

Code
model <- "fit04xPh"
pp(model)
fit04xPh: [df8] AgencyC ~ (TimeC | Name) + TimeC * Phase * Outcome
Code
## performance::check_zeroinflation(get(model))

Performance

Reclaim Model fit04aPh

Code
model <- "fit02aPh"
model <- "fit03aPh"
model <- "fit04aPh"
cat0(model)
fit04aPh 

Score

Code
file = file.path(
  ofd4, "summary-performance-score.png")

perf0 <- performance::compare_performance(
  fit01aPh, # [df0] Agency ~ (1 | Name) + 1
  fit02aPh, # [df0] Agency ~ (Time | Name) + Time
  fit03aPh, # [df0] Agency ~ (Time | Name) + Time * Phase
  fit04aPh, # [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
  ## CAUTION: COMMA
  rank = TRUE, verbose = FALSE)

perf0 %>% performance::print_html()
Comparison of Model Performance Indices
Name Model R2 (cond.) R2 (marg.) ICC RMSE Sigma AIC weights AICc weights BIC weights Performance-Score
fit04aPh lmerModLmerTest 0.10 0.02 0.08 0.26 0.26 1.00 1.00 1.00 84.61%
fit03aPh lmerModLmerTest 0.11 6.03e-03 0.10 0.26 0.26 2.51e-118 2.51e-118 7.03e-101 52.18%
fit02aPh lmerModLmerTest 0.10 4.62e-04 0.10 0.26 0.26 9.57e-321 9.58e-321 3.26e-290 40.78%
fit01aPh lmerModLmerTest 0.08 0.00 0.08 0.26 0.26 0.00e+00 0.00e+00 0.00e+00 0.99%
NA
Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- perf0 %>% plot()
ggsave(
  file = file,
  plot = gg88,
  width=8,
  height=6)

knitr::opts_chunk$set(fig.width=unit(12,"cm"), fig.height=unit(12,"cm"))
gg88

Performance Table Sorted by R2_conditional

Code
perf0 %>% dplyr::arrange(desc(R2_conditional)) %>% performance::print_html()
Comparison of Model Performance Indices
Name Model R2 (cond.) R2 (marg.) ICC RMSE Sigma AIC weights AICc weights BIC weights Performance-Score
fit03aPh lmerModLmerTest 0.11 6.03e-03 0.10 0.26 0.26 2.51e-118 2.51e-118 7.03e-101 52.18%
fit02aPh lmerModLmerTest 0.10 4.62e-04 0.10 0.26 0.26 9.57e-321 9.58e-321 3.26e-290 40.78%
fit04aPh lmerModLmerTest 0.10 0.02 0.08 0.26 0.26 1.00 1.00 1.00 84.61%
fit01aPh lmerModLmerTest 0.08 0.00 0.08 0.26 0.26 0.00e+00 0.00e+00 0.00e+00 0.99%
NA

Performance Table Sorted by R2_marginal

Code
perf0 %>% dplyr::arrange(desc(R2_marginal)) %>% performance::print_html()
Comparison of Model Performance Indices
Name Model R2 (cond.) R2 (marg.) ICC RMSE Sigma AIC weights AICc weights BIC weights Performance-Score
fit04aPh lmerModLmerTest 0.10 0.02 0.08 0.26 0.26 1.00 1.00 1.00 84.61%
fit03aPh lmerModLmerTest 0.11 6.03e-03 0.10 0.26 0.26 2.51e-118 2.51e-118 7.03e-101 52.18%
fit02aPh lmerModLmerTest 0.10 4.62e-04 0.10 0.26 0.26 9.57e-321 9.58e-321 3.26e-290 40.78%
fit01aPh lmerModLmerTest 0.08 0.00 0.08 0.26 0.26 0.00e+00 0.00e+00 0.00e+00 0.99%
NA

Interpret R2

Code
model <- "fit01aPh" # [df0] Agency ~ (1 | Name) + 1
model <- "fit02aPh" # [df0] Agency ~ (Time | Name) + Time
model <- "fit03aPh" # [df0] Agency ~ (Time | Name) + Time * Phase
model <- "fit04aPh" # [df0] Agency ~ (Time | Name) + Time * Phase * Outcome

cat0(effectsize::interpret_r2(performance::r2(get(model))$R2_conditional, rules="cohen1988"))
weak 
Code
cat0(effectsize::interpret_r2(performance::r2(get(model))$R2_marginal, rules="cohen1988"))
weak 

Plot models

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- sjPlot::plot_models(
  ## CAUTION the null model can not be used here 
  ## Thus to keep the numbers consistent I have 
  ## used model 02 as an input twice
  ## fit01aPh, # [df0] Agency ~ (Time | Name) + Time
  fit02aPh, # [df0] Agency ~ (Time | Name) + Time
  fit03aPh, # [df0] Agency ~ (Time | Name) + Time * Phase
  fit04aPh, # [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
  m.labels = c("Model 2", "Model 3", "Model 4"),
  spacing=1, 
  dot.size=1
) + line0h

ggsave(
  file = file.path(ofd4, "summary-plot-models-i0001-base.png"),
  plot = gg88,
  width=5,
  height=4)

knitr::opts_chunk$set(fig.width=unit(12,"cm"), fig.height=unit(16,"cm"))
gg88

Tabulate Models

Code
## library(sjPlot)
## library(sjmisc)
## library(sjlabelled)

file <- file.path(ofd4, "summary-tab-model-i0001-base.html")
sjPlot::tab_model(
  fit01aPh, # [df0] Agency ~ (1 | Name) + 1
  fit02aPh, # [df0] Agency ~ (Time | Name) + Time
  fit03aPh, # [df0] Agency ~ (Time | Name) + Time * Phase
  fit04aPh, # [df0] Agency ~ (Time | Name) + Time * Phase * Outcome
  show.reflvl = FALSE,
  show.intercept = TRUE,
  show.p = FALSE,
  p.style = "numeric_stars",
  dv.labels = c("Model 1", "Model 2", "Model 3", "Model 4"),
  wrap.labels = 225,  
  file = file)
  Model 1 Model 2 Model 3 Model 4
Predictors Estimates CI Estimates CI Estimates CI Estimates CI
(Intercept) 0.50 *** 0.49 – 0.50 0.50 *** 0.49 – 0.50 0.53 *** 0.52 – 0.53 0.52 *** 0.51 – 0.52
Time -0.01 *** -0.02 – -0.01 0.04 *** 0.04 – 0.05 0.06 *** 0.05 – 0.07
Phase [AE] -0.00 -0.01 – 0.00 -0.04 *** -0.06 – -0.03
Phase [BR] -0.57 *** -0.63 – -0.51 -0.50 *** -0.61 – -0.38
Phase [AR] -0.01 -0.02 – 0.00 -0.12 *** -0.14 – -0.10
Time × Phase [AE] -0.36 *** -0.41 – -0.31 -0.49 *** -0.59 – -0.39
Time × Phase [BR] 1.61 *** 1.42 – 1.80 1.15 *** 0.78 – 1.52
Time × Phase [AR] -0.10 *** -0.11 – -0.09 -0.06 *** -0.09 – -0.03
Outcome [winner] 0.02 *** 0.01 – 0.04
Time × Outcome [winner] -0.02 ** -0.03 – -0.01
Phase [AE] × Outcome [winner] 0.06 *** 0.04 – 0.08
Phase [BR] × Outcome [winner] -0.09 -0.23 – 0.04
Phase [AR] × Outcome [winner] 0.15 *** 0.12 – 0.17
(Time × Phase [AE]) × Outcome [winner] 0.17 ** 0.05 – 0.28
(Time × Phase [BR]) × Outcome [winner] 0.63 ** 0.19 – 1.06
(Time × Phase [AR]) × Outcome [winner] -0.04 ** -0.08 – -0.01
Random Effects
σ2 0.07 0.07 0.07 0.07
τ00 0.01 Name 0.01 Name 0.01 Name 0.00 Name
τ11   0.00 Name.Time 0.00 Name.Time 0.00 Name.Time
ρ01   0.18 Name 0.18 Name -0.07 Name
ICC 0.08 0.10 0.10 0.08
N 870 Name 870 Name 870 Name 870 Name
Observations 169997 169997 169997 169997
Marginal R2 / Conditional R2 0.000 / 0.084 0.000 / 0.102 0.006 / 0.107 0.021 / 0.102
* p<0.05   ** p<0.01   *** p<0.001
Code
## knitr::html
## papaja::
## rmarkdown::render
## rmarkdown::render(tab0$knitr)
## tab0$knitr
cat0(file)
./data/20240428T200156-politicians-aux-analysis/n0001-init//n0001-models-phase-i0021-all/summary-tab-model-i0001-base.html 
  • tab_model

  • [Click to reveal](./data/20240428T200156-politicians-aux-analysis/n0001-init//n0001-models-phase-i0021-all/summary-tab-model-i0001-base.html)
Code
save.image(file=file.path(ofd4, "session3.RData"))
## load(file.path(ofd4, "session3.RData")

Report

Code
result9 <- report::report(fit04aPh)
Code
print(result9)
We fitted a linear mixed model (estimated using REML and Nelder-Mead optimizer)
to predict Agency with Time, Phase and Outcome (formula: Agency ~ Time * Phase
* Outcome). The model included Time as random effects (formula: ~Time | Name).
The model's total explanatory power is weak (conditional R2 = 0.10) and the
part related to the fixed effects alone (marginal R2) is of 0.02. The model's
intercept, corresponding to Time = 0, Phase = BE and Outcome = loser, is at
0.52 (95% CI [0.51, 0.52], t(169977) = 115.77, p < .001). Within this model:

  - The effect of Time is statistically significant and positive (beta = 0.06,
95% CI [0.05, 0.07], t(169977) = 10.19, p < .001; Std. beta = 0.12, 95% CI
[0.10, 0.14])
  - The effect of Phase [AE] is statistically significant and negative (beta =
-0.04, 95% CI [-0.06, -0.03], t(169977) = -5.52, p < .001; Std. beta = -0.03,
95% CI [-0.11, 0.04])
  - The effect of Phase [BR] is statistically significant and negative (beta =
-0.50, 95% CI [-0.61, -0.38], t(169977) = -8.24, p < .001; Std. beta = -2.12,
95% CI [-2.65, -1.60])
  - The effect of Phase [AR] is statistically significant and negative (beta =
-0.12, 95% CI [-0.14, -0.10], t(169977) = -11.56, p < .001; Std. beta = -0.43,
95% CI [-0.51, -0.35])
  - The effect of Outcome [winner] is statistically significant and positive
(beta = 0.02, 95% CI [0.01, 0.04], t(169977) = 4.07, p < .001; Std. beta =
0.09, 95% CI [0.05, 0.13])
  - The effect of Time × Phase [AE] is statistically significant and negative
(beta = -0.49, 95% CI [-0.59, -0.39], t(169977) = -9.71, p < .001; Std. beta =
-1.04, 95% CI [-1.25, -0.83])
  - The effect of Time × Phase [BR] is statistically significant and positive
(beta = 1.15, 95% CI [0.78, 1.52], t(169977) = 6.05, p < .001; Std. beta =
2.43, 95% CI [1.64, 3.22])
  - The effect of Time × Phase [AR] is statistically significant and negative
(beta = -0.06, 95% CI [-0.09, -0.03], t(169977) = -3.82, p < .001; Std. beta =
-0.12, 95% CI [-0.19, -0.06])
  - The effect of Time × Outcome [winner] is statistically significant and
negative (beta = -0.02, 95% CI [-0.03, -6.28e-03], t(169977) = -2.83, p =
0.005; Std. beta = -0.04, 95% CI [-0.07, -0.01])
  - The effect of Phase [AE] × Outcome [winner] is statistically significant and
positive (beta = 0.06, 95% CI [0.04, 0.08], t(169977) = 6.32, p < .001; Std.
beta = 0.17, 95% CI [0.08, 0.26])
  - The effect of Phase [BR] × Outcome [winner] is statistically non-significant
and negative (beta = -0.09, 95% CI [-0.23, 0.04], t(169977) = -1.34, p = 0.179;
Std. beta = -0.50, 95% CI [-1.12, 0.11])
  - The effect of Phase [AR] × Outcome [winner] is statistically significant and
positive (beta = 0.15, 95% CI [0.12, 0.17], t(169977) = 12.55, p < .001; Std.
beta = 0.56, 95% CI [0.47, 0.65])
  - The effect of (Time × Phase [AE]) × Outcome [winner] is statistically
significant and positive (beta = 0.17, 95% CI [0.05, 0.28], t(169977) = 2.85, p
= 0.004; Std. beta = 0.35, 95% CI [0.11, 0.60])
  - The effect of (Time × Phase [BR]) × Outcome [winner] is statistically
significant and positive (beta = 0.63, 95% CI [0.19, 1.06], t(169977) = 2.83, p
= 0.005; Std. beta = 1.32, 95% CI [0.41, 2.24])
  - The effect of (Time × Phase [AR]) × Outcome [winner] is statistically
significant and negative (beta = -0.04, 95% CI [-0.08, -0.01], t(169977) =
-2.59, p = 0.010; Std. beta = -0.09, 95% CI [-0.17, -0.02])

Standardized parameters were obtained by fitting the model on a standardized
version of the dataset. 95% Confidence Intervals (CIs) and p-values were
computed using a Wald t-distribution approximation.

glmmTMB Models

Code
library(glmmTMB)

count5 = 1e3
count5 = 15e3

df5 <- df2 %>% 
  dplyr::group_by(Phase) %>% 
  dplyr::slice_sample(n=count5) %>%
  identity()

df5 %>% dim()
[1] 60000    22
Code
df5 %>% 
  dplyr::group_by(Phase) %>% 
  dplyr::summarize(Count = n()) %>%
  identity()
# A tibble: 4 × 2
  Phase Count
  <fct> <int>
1 BE    15000
2 AE    15000
3 BR    15000
4 AR    15000

Model xFit05aPhLikes

Fit

Code
model <- "xFit05aPhLikes"
suppressWarnings(rm(list = model))
assign(
  model,
  glmmTMB::glmmTMB(
    formula = LikeCount ~ Agency * Phase  + (1 | Name),
    ziformula = ~ Agency * Phase,
    family = truncated_poisson,
    data = df5
  ))

fbase <- get_model_info(model, ofd4)
xFit05aPhLikes: [df5] LikeCount ~ Agency * Phase + (1 | Name)
 Family: truncated_poisson  ( log )
Formula:          LikeCount ~ Agency * Phase + (1 | Name)
Zero inflation:             ~Agency * Phase
Data: df5

       AIC        BIC     logLik   deviance   df.resid 
 211146817  211146970 -105573392  211146783      59983 

Random effects:

Conditional model:
 Groups Name        Variance Std.Dev.
 Name   (Intercept) 3.97     1.993   
Number of obs: 60000, groups:  Name, 845

Conditional model:
                 Estimate Std. Error z value Pr(>|z|)    
(Intercept)     3.8581581  0.0690181    55.9   <2e-16 ***
Agency          0.0444432  0.0009483    46.9   <2e-16 ***
PhaseAE         0.7681026  0.0006708  1145.1   <2e-16 ***
PhaseBR         1.0178189  0.0006548  1554.3   <2e-16 ***
PhaseAR         0.6531470  0.0007137   915.2   <2e-16 ***
Agency:PhaseAE  0.0891286  0.0010687    83.4   <2e-16 ***
Agency:PhaseBR  0.3487010  0.0010217   341.3   <2e-16 ***
Agency:PhaseAR -0.3890907  0.0011529  -337.5   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Zero-inflation model:
               Estimate Std. Error z value Pr(>|z|)    
(Intercept)    -3.01127    0.06779  -44.42  < 2e-16 ***
Agency         -0.69005    0.12165   -5.67 1.41e-08 ***
PhaseAE         0.02190    0.09269    0.24 0.813210    
PhaseBR        -0.26488    0.09474   -2.80 0.005177 ** 
PhaseAR        -0.36530    0.10327   -3.54 0.000404 ***
Agency:PhaseAE -0.41565    0.17241   -2.41 0.015915 *  
Agency:PhaseBR -0.24252    0.17176   -1.41 0.157968    
Agency:PhaseAR -0.42872    0.19291   -2.22 0.026259 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------------------------------- 
xFit05aPhLikes: [df5] LikeCount ~ Agency * Phase + (1 | Name)
# R2 for Mixed Models

  Conditional R2: 1.000
     Marginal R2: 0.048
--------------------------------------------------------------------- 
xFit05aPhLikes: [df5] LikeCount ~ Agency * Phase + (1 | Name)
# Intraclass Correlation Coefficient

    Adjusted ICC: 1.000
  Unadjusted ICC: 0.952
--------------------------------------------------------------------- 
xFit05aPhLikes: [df5] LikeCount ~ Agency * Phase + (1 | Name)
# ICC by Group

Group |   ICC
-------------
Name  | 1.000
--------------------------------------------------------------------- 

Effects: Agency x Phase

Compute

Code
model <- "xFit05aPhLikes"
extra <- "1003"
terms <- c("Agency", "Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit05aPhLikes: [df5] LikeCount ~ Agency * Phase + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of LikeCount

Phase: BE

Agency | Predicted |          95% CI
------------------------------------
    -3 |    439.89 | 338.63,  541.15
    -2 |    534.69 | 483.58,  585.79
    -1 |    608.64 | 589.55,  627.73
     0 |    665.97 | 661.75,  670.19
     1 |    712.90 | 709.97,  715.84
     2 |    754.36 | 750.18,  758.54
     3 |    793.48 | 788.67,  798.29

Phase: AE

Agency | Predicted |           95% CI
-------------------------------------
    -3 |    422.54 |  224.64,  620.44
    -2 |    790.18 |  648.74,  931.61
    -1 |   1144.00 | 1093.44, 1194.55
     0 |   1434.09 | 1425.54, 1442.64
     1 |   1693.30 | 1688.14, 1698.46
     2 |   1956.72 | 1951.46, 1961.98
     3 |   2244.57 | 2238.48, 2250.66

Phase: BR

Agency | Predicted |           95% CI
-------------------------------------
    -3 |    367.02 |  254.79,  479.25
    -2 |    708.09 |  629.73,  786.44
    -1 |   1190.71 | 1155.91, 1225.50
     0 |   1863.14 | 1854.29, 1871.98
     1 |   2822.79 | 2814.92, 2830.66
     2 |   4219.82 | 4208.77, 4230.87
     3 |   6274.35 | 6259.58, 6289.12

Phase: AR

Agency | Predicted |           95% CI
-------------------------------------
    -3 |   1907.02 |  972.47, 2841.56
    -2 |   2026.34 | 1682.63, 2370.05
    -1 |   1715.75 | 1648.67, 1782.83
     0 |   1298.33 | 1291.71, 1304.95
     1 |    940.76 |  938.34,  943.18
     2 |    671.50 |  669.68,  673.32
     3 |    476.91 |  475.28,  478.55
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Agency

Phase |   Slope |          95% CI |      p
------------------------------------------
BE    |   37.85 |   26.15,  49.56 | < .001
AE    |  188.95 |  172.41, 205.49 | < .001
BR    |  652.36 |  641.39, 663.33 | < .001
AR    | -112.11 | -219.96,  -4.27 | 0.042 

Slopes are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Agency

Phase | Contrast |           95% CI |      p
--------------------------------------------
BE-AE |  -151.10 | -171.36, -130.84 | < .001
BE-BR |  -614.51 | -630.55, -598.47 | < .001
BE-AR |   149.96 |   41.48,  258.44 | 0.007 
AE-BR |  -463.41 | -483.25, -443.56 | < .001
AE-AR |   301.06 |  191.96,  410.17 | < .001
BR-AR |   764.47 |  656.07,  872.87 | < .001

Contrasts are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Phase

Compute

Code
model <- "xFit05aPhLikes"
extra <- "1002"
terms <- c("Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit05aPhLikes: [df5] LikeCount ~ Agency * Phase + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of LikeCount

Phase | Predicted |           95% CI
------------------------------------
BE    |    689.64 |  687.50,  691.79
AE    |   1563.30 | 1558.93, 1567.66
BR    |   2322.87 | 2317.19, 2328.56
AR    |   1116.05 | 1113.11, 1118.98
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
Phase | Predicted |           95% CI |      p
---------------------------------------------
BE    |    689.64 |  687.50,  691.79 | < .001
AE    |   1563.30 | 1558.93, 1567.66 | < .001
BR    |   2322.87 | 2317.19, 2328.56 | < .001
AR    |   1116.05 | 1113.11, 1118.98 | < .001

Predictions are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# Pairwise comparisons

Phase | Contrast |             95% CI |      p
----------------------------------------------
BE-AE |  -873.65 |  -878.53,  -868.78 | < .001
BE-BR | -1633.23 | -1639.32, -1627.14 | < .001
BE-AR |  -426.40 |  -430.05,  -422.75 | < .001
AE-BR |  -759.58 |  -766.77,  -752.39 | < .001
AE-AR |   447.25 |   441.97,   452.52 | < .001
BR-AR |  1206.83 |  1200.41,  1213.24 | < .001

Contrasts are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Agency

Compute

Code
model <- "xFit05aPhLikes"
extra <- "1001"
terms <- c("Agency")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit05aPhLikes: [df5] LikeCount ~ Agency * Phase + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of LikeCount

Agency | Predicted |           95% CI
-------------------------------------
    -3 |    767.94 |  532.79, 1003.10
    -2 |   1016.19 |  920.78, 1111.61
    -1 |   1192.23 | 1168.10, 1216.37
     0 |   1373.61 | 1369.70, 1377.53
     1 |   1638.24 | 1635.49, 1641.00
     2 |   2045.81 | 2042.28, 2049.35
     3 |   2660.66 | 2656.07, 2665.24
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Agency

Slope  |         95% CI |      p
--------------------------------
268.82 | 263.37, 274.28 | < .001

Slopes are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Agency

Slope  |         95% CI |      p
--------------------------------
268.82 | 263.37, 274.28 | < .001

Slopes are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Model xFit06aPhRetweets

Fit

Code
model <- "xFit06aPhRetweets"
suppressWarnings(rm(list = model))
assign(
  model,
  glmmTMB::glmmTMB(
    formula = RetweetCount ~ Agency * Phase  + (1 | Name),
    ziformula = ~ Agency * Phase,
    family = truncated_poisson,
    data = df5
  ))

fbase <- get_model_info(model, ofd4)
xFit06aPhRetweets: [df5] RetweetCount ~ Agency * Phase + (1 | Name)
 Family: truncated_poisson  ( log )
Formula:          RetweetCount ~ Agency * Phase + (1 | Name)
Zero inflation:                ~Agency * Phase
Data: df5

      AIC       BIC    logLik  deviance  df.resid 
 36974200  36974353 -18487083  36974166     59983 

Random effects:

Conditional model:
 Groups Name        Variance Std.Dev.
 Name   (Intercept) 3.23     1.797   
Number of obs: 60000, groups:  Name, 845

Conditional model:
                Estimate Std. Error z value Pr(>|z|)    
(Intercept)     2.849823   0.062872    45.3  < 2e-16 ***
Agency          0.011655   0.001890     6.2 7.04e-10 ***
PhaseAE         0.238168   0.001431   166.5  < 2e-16 ***
PhaseBR         0.615614   0.001350   455.9  < 2e-16 ***
PhaseAR         0.335873   0.001485   226.2  < 2e-16 ***
Agency:PhaseAE  0.166094   0.002284    72.7  < 2e-16 ***
Agency:PhaseBR  0.259858   0.002118   122.7  < 2e-16 ***
Agency:PhaseAR -0.371597   0.002428  -153.1  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Zero-inflation model:
               Estimate Std. Error z value Pr(>|z|)    
(Intercept)    -2.56827    0.05591  -45.94  < 2e-16 ***
Agency         -0.50021    0.09756   -5.13 2.94e-07 ***
PhaseAE         0.28850    0.07332    3.93 8.32e-05 ***
PhaseBR         0.13146    0.07268    1.81 0.070479 .  
PhaseAR        -0.01566    0.07860   -0.20 0.842041    
Agency:PhaseAE -0.71883    0.13485   -5.33 9.79e-08 ***
Agency:PhaseBR -0.39487    0.12916   -3.06 0.002234 ** 
Agency:PhaseAR -0.54609    0.14311   -3.82 0.000136 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------------------------------- 
xFit06aPhRetweets: [df5] RetweetCount ~ Agency * Phase + (1 | Name)
# R2 for Mixed Models

  Conditional R2: 1.000
     Marginal R2: 0.026
--------------------------------------------------------------------- 
xFit06aPhRetweets: [df5] RetweetCount ~ Agency * Phase + (1 | Name)
# Intraclass Correlation Coefficient

    Adjusted ICC: 1.000
  Unadjusted ICC: 0.974
--------------------------------------------------------------------- 
xFit06aPhRetweets: [df5] RetweetCount ~ Agency * Phase + (1 | Name)
# ICC by Group

Group |   ICC
-------------
Name  | 1.000
--------------------------------------------------------------------- 

Effects: Agency x Phase

Compute

Code
model <- "xFit06aPhRetweets"
extra <- "1003"
terms <- c("Agency", "Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit06aPhRetweets: [df5] RetweetCount ~ Agency * Phase + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of RetweetCount

Phase: BE

Agency | Predicted |         95% CI
-----------------------------------
    -3 |    127.72 | 106.01, 149.43
    -2 |    143.69 | 131.89, 155.48
    -1 |    155.96 | 150.90, 161.02
     0 |    165.08 | 163.74, 166.42
     1 |    171.83 | 170.79, 172.88
     2 |    176.94 | 175.14, 178.73
     3 |    180.96 | 178.70, 183.23

Phase: AE

Agency | Predicted |         95% CI
-----------------------------------
    -3 |     26.66 |  13.59,  39.73
    -2 |     72.79 |  55.78,  89.80
    -1 |    140.25 | 131.05, 149.44
     0 |    204.58 | 202.79, 206.38
     1 |    261.47 | 260.34, 262.60
     2 |    318.92 | 317.41, 320.42
     3 |    383.34 | 380.86, 385.82

Phase: BR

Agency | Predicted |         95% CI
-----------------------------------
    -3 |     63.84 |  43.73,  83.96
    -2 |    125.42 | 108.31, 142.53
    -1 |    206.51 | 197.93, 215.10
     0 |    302.46 | 300.21, 304.70
     1 |    416.61 | 414.73, 418.50
     2 |    557.95 | 555.21, 560.70
     3 |    738.28 | 734.33, 742.23

Phase: AR

Agency | Predicted |         95% CI
-----------------------------------
    -3 |    266.98 | 148.88, 385.08
    -2 |    316.88 | 257.57, 376.19
    -1 |    293.33 | 278.14, 308.53
     0 |    231.21 | 229.40, 233.01
     1 |    169.03 | 168.30, 169.76
     2 |    119.98 | 119.30, 120.66
     3 |     84.26 |  83.60,  84.93
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Agency

Phase |  Slope |        95% CI |      p
---------------------------------------
BE    |   5.82 |   3.18,  8.45 | < .001
AE    |  36.70 |  35.81, 37.59 | < .001
BR    |  72.78 |  70.91, 74.65 | < .001
AR    | -13.80 | -26.06, -1.54 | 0.027 

Slopes are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Agency

Phase | Contrast |         95% CI |      p
------------------------------------------
BE-AE |   -30.88 | -33.66, -28.10 | < .001
BE-BR |   -66.96 | -70.20, -63.73 | < .001
BE-AR |    19.62 |   7.08,  32.16 | 0.002 
AE-BR |   -36.08 | -38.15, -34.01 | < .001
AE-AR |    50.50 |  38.21,  62.79 | < .001
BR-AR |    86.58 |  74.18,  98.99 | < .001

Contrasts are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Phase

Compute

Code
model <- "xFit06aPhRetweets"
extra <- "1002"
terms <- c("Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit06aPhRetweets: [df5] RetweetCount ~ Agency * Phase + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of RetweetCount

Phase | Predicted |         95% CI
----------------------------------
BE    |    168.53 | 167.83, 169.23
AE    |    233.02 | 232.11, 233.93
BR    |    358.09 | 356.72, 359.45
AR    |    199.73 | 198.94, 200.52
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
Phase | Predicted |         95% CI |      p
-------------------------------------------
BE    |    168.53 | 167.83, 169.23 | < .001
AE    |    233.02 | 232.11, 233.93 | < .001
BR    |    358.09 | 356.72, 359.45 | < .001
AR    |    199.73 | 198.94, 200.52 | < .001

Predictions are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# Pairwise comparisons

Phase | Contrast |           95% CI |      p
--------------------------------------------
BE-AE |   -64.49 |  -65.65,  -63.33 | < .001
BE-BR |  -189.56 | -191.11, -188.01 | < .001
BE-AR |   -31.20 |  -32.27,  -30.14 | < .001
AE-BR |  -125.07 | -126.72, -123.41 | < .001
AE-AR |    33.29 |   32.07,   34.50 | < .001
BR-AR |   158.36 |  156.77,  159.94 | < .001

Contrasts are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Agency

Compute

Code
model <- "xFit06aPhRetweets"
extra <- "1001"
terms <- c("Agency")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit06aPhRetweets: [df5] RetweetCount ~ Agency * Phase + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of RetweetCount

Agency | Predicted |         95% CI
-----------------------------------
    -3 |    114.59 |  85.01, 144.16
    -2 |    160.17 | 144.15, 176.18
    -1 |    198.88 | 193.68, 204.08
     0 |    230.98 | 230.03, 231.93
     1 |    265.63 | 264.96, 266.30
     2 |    310.95 | 309.99, 311.91
     3 |    372.26 | 370.86, 373.65
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Agency

Slope |       95% CI |      p
-----------------------------
35.04 | 33.72, 36.36 | < .001

Slopes are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Agency

Slope |       95% CI |      p
-----------------------------
35.04 | 33.72, 36.36 | < .001

Slopes are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Model: xFit05oPhLikes (+Outcome)

Fit

Code
model <- "xFit05oPhLikes"
suppressWarnings(rm(list = model))
assign(
  model,
  glmmTMB::glmmTMB(
    formula = LikeCount ~ Agency * Phase * Outcome  + (1 | Name),
    ziformula = ~ Agency * Phase * Outcome,
    family = truncated_poisson,
    data = df5
  ))
Warning in finalizeTMB(TMBStruc, obj, fit, h, data.tmb.old): Model convergence
problem; function evaluation limit reached without convergence (9). See
vignette('troubleshooting'), help('diagnose')
Code
fbase <- get_model_info(model, ofd4)
xFit05oPhLikes: [df5] LikeCount ~ Agency * Phase * Outcome + (1 | Name)
 Family: truncated_poisson  ( log )
Formula:          LikeCount ~ Agency * Phase * Outcome + (1 | Name)
Zero inflation:             ~Agency * Phase * Outcome
Data: df5

       AIC        BIC     logLik   deviance   df.resid 
 210486627  210486924 -105243280  210486561      59967 

Random effects:

Conditional model:
 Groups Name        Variance Std.Dev.
 Name   (Intercept) 3.615    1.901   
Number of obs: 60000, groups:  Name, 845

Conditional model:
                              Estimate Std. Error z value Pr(>|z|)    
(Intercept)                   3.369100   0.101596    33.2  < 2e-16 ***
Agency                       -0.053785   0.002022   -26.6  < 2e-16 ***
PhaseAE                       0.460565   0.001648   279.4  < 2e-16 ***
PhaseBR                       0.453566   0.001482   306.0  < 2e-16 ***
PhaseAR                       0.641751   0.001520   422.2  < 2e-16 ***
Outcomewinner                 0.939564   0.133452     7.0 1.92e-12 ***
Agency:PhaseAE                0.319924   0.002754   116.1  < 2e-16 ***
Agency:PhaseBR                0.278548   0.002488   111.9  < 2e-16 ***
Agency:PhaseAR               -0.550491   0.002756  -199.7  < 2e-16 ***
Agency:Outcomewinner          0.153101   0.002291    66.8  < 2e-16 ***
PhaseAE:Outcomewinner         0.395588   0.001814   218.1  < 2e-16 ***
PhaseBR:Outcomewinner         0.690471   0.001658   416.4  < 2e-16 ***
PhaseAR:Outcomewinner         0.040590   0.001723    23.6  < 2e-16 ***
Agency:PhaseAE:Outcomewinner -0.291761   0.003002   -97.2  < 2e-16 ***
Agency:PhaseBR:Outcomewinner  0.007423   0.002740     2.7  0.00676 ** 
Agency:PhaseAR:Outcomewinner  0.176475   0.003042    58.0  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Zero-inflation model:
                             Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  -2.52762    0.08242 -30.669  < 2e-16 ***
Agency                       -0.62818    0.15006  -4.186 2.84e-05 ***
PhaseAE                       0.44327    0.11008   4.027 5.65e-05 ***
PhaseBR                       0.11842    0.11018   1.075    0.282    
PhaseAR                       0.19703    0.12039   1.637    0.102    
Outcomewinner                -1.10911    0.14707  -7.542 4.65e-14 ***
Agency:PhaseAE               -0.02376    0.20907  -0.114    0.910    
Agency:PhaseBR                0.23911    0.20535   1.164    0.244    
Agency:PhaseAR                0.09670    0.23315   0.415    0.678    
Agency:Outcomewinner          0.06739    0.25961   0.260    0.795    
PhaseAE:Outcomewinner        -0.91942    0.21342  -4.308 1.65e-05 ***
PhaseBR:Outcomewinner        -1.40170    0.25511  -5.495 3.92e-08 ***
PhaseAR:Outcomewinner        -1.29074    0.25067  -5.149 2.62e-07 ***
Agency:PhaseAE:Outcomewinner -0.17534    0.38579  -0.454    0.649    
Agency:PhaseBR:Outcomewinner -0.37387    0.44640  -0.838    0.402    
Agency:PhaseAR:Outcomewinner  0.15817    0.43757   0.361    0.718    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------------------------------- 
xFit05oPhLikes: [df5] LikeCount ~ Agency * Phase * Outcome + (1 | Name)
# R2 for Mixed Models

  Conditional R2: 1.000
     Marginal R2: 0.132
--------------------------------------------------------------------- 
xFit05oPhLikes: [df5] LikeCount ~ Agency * Phase * Outcome + (1 | Name)
# Intraclass Correlation Coefficient

    Adjusted ICC: 1.000
  Unadjusted ICC: 0.868
--------------------------------------------------------------------- 
xFit05oPhLikes: [df5] LikeCount ~ Agency * Phase * Outcome + (1 | Name)
# ICC by Group

Group |   ICC
-------------
Name  | 1.000
--------------------------------------------------------------------- 

Effects: Agency x Outcome x Phase

Compute

Code
model <- "xFit05oPhLikes"
extra <- "1005"
terms <- c("Agency", "Outcome", "Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit05oPhLikes: [df5] LikeCount ~ Agency * Phase * Outcome + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of LikeCount

Outcome: loser
Phase: BE

Agency | Predicted |          95% CI
------------------------------------
    -3 |    249.30 | 151.75,  346.85
    -2 |    281.48 | 214.16,  348.80
    -1 |    297.10 | 240.99,  353.22
     0 |    299.75 | 245.55,  353.94
     1 |    294.20 | 241.06,  347.34
     2 |    284.21 | 232.82,  335.61
     3 |    272.16 | 222.92,  321.39

Outcome: loser
Phase: AE

Agency | Predicted |          95% CI
------------------------------------
    -3 |    122.86 |  63.85,  181.87
    -2 |    206.62 | 149.37,  263.86
    -1 |    317.37 | 255.31,  379.43
     0 |    456.24 | 373.60,  538.89
     1 |    628.66 | 514.89,  742.44
     2 |    844.98 | 691.82,  998.15
     3 |   1120.16 | 917.19, 1323.12

Outcome: loser
Phase: BR

Agency | Predicted |          95% CI
------------------------------------
    -3 |    201.42 | 146.25,  256.58
    -2 |    271.79 | 214.90,  328.69
    -1 |    359.23 | 292.46,  426.01
     0 |    467.40 | 382.88,  551.93
     1 |    601.18 | 492.43,  709.92
     2 |    766.88 | 627.70,  906.05
     3 |    972.57 | 795.82, 1149.32

Outcome: loser
Phase: AR

Agency | Predicted |           95% CI
-------------------------------------
    -3 |   2547.63 | 1484.65, 3610.62
    -2 |   1606.72 | 1198.13, 2015.32
    -1 |    965.46 |  779.48, 1151.44
     0 |    560.40 |  458.92,  661.88
     1 |    317.87 |  260.31,  375.43
     2 |    177.71 |  145.45,  209.96
     3 |     98.51 |   80.66,  116.36

Outcome: winner
Phase: BE

Agency | Predicted |           95% CI
-------------------------------------
    -3 |    538.52 |  432.76,  644.29
    -2 |    628.21 |  557.91,  698.51
    -1 |    716.82 |  655.42,  778.22
     0 |    806.94 |  741.30,  872.58
     1 |    901.13 |  827.94,  974.31
     2 |   1001.58 |  920.09, 1083.07
     3 |   1110.22 | 1019.80, 1200.63

Outcome: winner
Phase: AE

Agency | Predicted |           95% CI
-------------------------------------
    -3 |   1146.68 |  869.00, 1424.36
    -2 |   1405.74 | 1243.63, 1567.85
    -1 |   1658.28 | 1518.08, 1798.49
     0 |   1918.25 | 1762.45, 2074.05
     1 |   2197.89 | 2019.54, 2376.24
     2 |   2506.85 | 2303.38, 2710.32
     3 |   2853.10 | 2621.51, 3084.68

Outcome: winner
Phase: BR

Agency | Predicted |           95% CI
-------------------------------------
    -3 |    773.00 |  657.39,  888.62
    -2 |   1168.88 | 1059.91, 1277.85
    -1 |   1743.19 | 1599.71, 1886.67
     0 |   2581.20 | 2371.73, 2790.67
     1 |   3808.28 | 3499.35, 4117.22
     2 |   5608.50 | 5153.46, 6063.54
     3 |   8252.18 | 7582.60, 8921.77

Outcome: winner
Phase: AR

Agency | Predicted |           95% CI
-------------------------------------
    -3 |   3654.95 | 3315.23, 3994.67
    -2 |   2792.94 | 2556.53, 3029.35
    -1 |   2131.07 | 1956.65, 2305.48
     0 |   1624.25 | 1492.42, 1756.09
     1 |   1236.96 | 1136.59, 1337.33
     2 |    941.44 |  864.95, 1017.94
     3 |    716.21 |  657.95,  774.47
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Agency

Outcome | Phase |   Slope |           95% CI |      p
-----------------------------------------------------
loser   |    BE |    3.62 |   -7.06,   14.31 | 0.507 
loser   |    AE |  113.19 |   93.75,  132.63 | < .001
loser   |    BR |   87.36 |   71.81,  102.90 | < .001
loser   |    AR | -289.86 | -445.20, -134.52 | < .001
winner  |    BE |   64.09 |   49.90,   78.27 | < .001
winner  |    AE |  192.61 |  152.80,  232.43 | < .001
winner  |    BR |  885.71 |  795.66,  975.75 | < .001
winner  |    AR | -336.48 | -377.68, -295.28 | < .001

Slopes are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Agency

Outcome       | Phase | Contrast |             95% CI |      p
--------------------------------------------------------------
loser-loser   | BE-AE |  -109.57 |  -131.24,   -87.89 | < .001
loser-loser   | BE-BR |   -83.74 |  -102.16,   -65.31 | < .001
loser-loser   | BE-AR |   293.48 |   137.60,   449.36 | < .001
loser-winner  | BE-BE |   -60.47 |   -78.43,   -42.50 | < .001
loser-winner  | BE-AE |  -188.99 |  -230.48,  -147.50 | < .001
loser-winner  | BE-BR |  -882.09 |  -973.33,  -790.84 | < .001
loser-winner  | BE-AR |   340.10 |   298.01,   382.20 | < .001
loser-loser   | AE-BR |    25.83 |    15.51,    36.15 | < .001
loser-loser   | AE-AR |   403.04 |   241.15,   564.94 | < .001
loser-winner  | AE-BE |    49.10 |    20.57,    77.63 | < .001
loser-winner  | AE-AE |   -79.42 |  -131.09,   -27.76 | 0.003 
loser-winner  | AE-BR |  -772.52 |  -880.84,  -664.20 | < .001
loser-winner  | AE-AR |   449.67 |   420.63,   478.71 | < .001
loser-loser   | BR-AR |   377.21 |   216.95,   537.48 | < .001
loser-winner  | BR-BE |    23.27 |    -1.71,    48.25 | 0.070 
loser-winner  | BR-AE |  -105.25 |  -153.96,   -56.55 | < .001
loser-winner  | BR-BR |  -798.35 |  -902.54,  -694.15 | < .001
loser-winner  | BR-AR |   423.84 |   392.41,   455.27 | < .001
loser-winner  | AR-BE |  -353.94 |  -507.99,  -199.90 | < .001
loser-winner  | AR-AE |  -482.47 |  -637.09,  -327.85 | < .001
loser-winner  | AR-BR | -1175.56 | -1330.23, -1020.90 | < .001
loser-winner  | AR-AR |    46.63 |  -123.62,   216.87 | 0.591 
winner-winner | BE-AE |  -128.53 |  -167.73,   -89.32 | < .001
winner-winner | BE-BR |  -821.62 |  -906.24,  -737.00 | < .001
winner-winner | BE-AR |   400.57 |   352.25,   448.88 | < .001
winner-winner | AE-BR |  -693.09 |  -772.10,  -614.09 | < .001
winner-winner | AE-AR |   529.09 |   461.33,   596.86 | < .001
winner-winner | BR-AR |  1222.19 |  1096.38,  1347.99 | < .001

Contrasts are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Phase x Outcome

Compute

Code
model <- "xFit05oPhLikes"
extra <- "1004"
terms <- c("Phase", "Outcome")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit05oPhLikes: [df5] LikeCount ~ Agency * Phase * Outcome + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of LikeCount

Outcome: loser

Phase | Predicted |           95% CI
------------------------------------
BE    |    297.37 |  243.72,  351.03
AE    |    536.90 |  439.04,  634.76
BR    |    530.02 |  433.63,  626.41
AR    |    438.30 |  360.29,  516.32

Outcome: winner

Phase | Predicted |           95% CI
------------------------------------
BE    |    851.75 |  783.08,  920.42
AE    |   2050.81 | 1885.79, 2215.83
BR    |   3145.50 | 2896.33, 3394.67
AR    |   1433.99 | 1315.77, 1552.21
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
Phase | Outcome | Predicted |           95% CI |      p
-------------------------------------------------------
BE    |   loser |    297.37 |  243.72,  351.03 | < .001
AE    |   loser |    536.90 |  439.04,  634.76 | < .001
BR    |   loser |    530.02 |  433.63,  626.41 | < .001
AR    |   loser |    438.30 |  360.29,  516.32 | < .001
BE    |  winner |    851.75 |  783.08,  920.42 | < .001
AE    |  winner |   2050.81 | 1885.79, 2215.83 | < .001
BR    |  winner |   3145.50 | 2896.33, 3394.67 | < .001
AR    |  winner |   1433.99 | 1315.77, 1552.21 | < .001

Predictions are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# Pairwise comparisons

Phase |       Outcome | Contrast |             95% CI |      p
--------------------------------------------------------------
BE-AE |   loser-loser |  -239.53 |  -283.99,  -195.07 | < .001
BE-BR |   loser-loser |  -232.65 |  -275.59,  -189.71 | < .001
BE-AR |   loser-loser |  -140.93 |  -165.69,  -116.17 | < .001
BE-BE |  loser-winner |  -554.37 |  -676.66,  -432.09 | < .001
BE-AE |  loser-winner | -1753.44 | -1972.08, -1534.80 | < .001
BE-BR |  loser-winner | -2848.13 | -3150.92, -2545.34 | < .001
BE-AR |  loser-winner | -1136.61 | -1308.46,  -964.77 | < .001
AE-BR |   loser-loser |     6.88 |    -0.21,    13.97 | 0.057 
AE-AR |   loser-loser |    98.60 |    77.57,   119.63 | < .001
AE-BE |  loser-winner |  -314.84 |  -481.29,  -148.40 | < .001
AE-AE |  loser-winner | -1513.91 | -1776.68, -1251.14 | < .001
AE-BR |  loser-winner | -2608.60 | -2955.51, -2261.68 | < .001
AE-AR |  loser-winner |  -897.08 | -1113.07,  -681.09 | < .001
BR-AR |   loser-loser |    91.72 |    72.25,   111.18 | < .001
BR-BE |  loser-winner |  -321.72 |  -486.71,  -156.74 | < .001
BR-AE |  loser-winner | -1520.79 | -1782.11, -1259.46 | < .001
BR-BR |  loser-winner | -2615.48 | -2960.95, -2270.01 | < .001
BR-AR |  loser-winner |  -903.96 | -1118.50,  -689.42 | < .001
AR-BE |  loser-winner |  -413.44 |  -560.04,  -266.84 | < .001
AR-AE |  loser-winner | -1612.51 | -1855.44, -1369.57 | < .001
AR-BR |  loser-winner | -2707.20 | -3034.27, -2380.12 | < .001
AR-AR |  loser-winner |  -995.68 | -1191.83,  -799.53 | < .001
BE-AE | winner-winner | -1199.06 | -1295.54, -1102.59 | < .001
BE-BR | winner-winner | -2293.76 | -2474.34, -2113.17 | < .001
BE-AR | winner-winner |  -582.24 |  -631.95,  -532.53 | < .001
AE-BR | winner-winner | -1094.69 | -1179.08, -1010.31 | < .001
AE-AR | winner-winner |   616.82 |   569.79,   663.86 | < .001
BR-AR | winner-winner |  1711.52 |  1580.48,  1842.55 | < .001

Contrasts are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Agency x Phase

Compute

Code
model <- "xFit05oPhLikes"
extra <- "1003"
terms <- c("Agency", "Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit05oPhLikes: [df5] LikeCount ~ Agency * Phase * Outcome + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of LikeCount

Phase: BE

Agency | Predicted |          95% CI
------------------------------------
    -3 |    448.83 | 377.16,  520.50
    -2 |    520.69 | 484.58,  556.80
    -1 |    586.66 | 572.10,  601.23
     0 |    649.66 | 645.99,  653.33
     1 |    712.92 | 710.17,  715.67
     2 |    779.13 | 774.52,  783.74
     3 |    850.33 | 844.52,  856.15

Phase: AE

Agency | Predicted |           95% CI
-------------------------------------
    -3 |    829.19 |  647.89, 1010.50
    -2 |   1033.89 |  953.25, 1114.53
    -1 |   1242.46 | 1214.14, 1270.79
     0 |   1464.88 | 1458.71, 1471.06
     1 |   1711.27 | 1706.52, 1716.03
     2 |   1991.50 | 1984.39, 1998.61
     3 |   2315.71 | 2307.08, 2324.34

Phase: BR

Agency | Predicted |           95% CI
-------------------------------------
    -3 |    595.75 |  527.51,  663.99
    -2 |    890.69 |  852.55,  928.83
    -1 |   1314.02 | 1296.42, 1331.63
     0 |   1925.71 | 1920.40, 1931.02
     1 |   2813.76 | 2808.63, 2818.88
     2 |   4107.11 | 4097.28, 4116.94
     3 |   5994.76 | 5979.38, 6010.15

Phase: AR

Agency | Predicted |           95% CI
-------------------------------------
    -3 |   3311.57 | 2993.07, 3630.07
    -2 |   2425.09 | 2324.34, 2525.84
    -1 |   1769.61 | 1743.74, 1795.48
     0 |   1294.35 | 1289.84, 1298.86
     1 |    951.95 |  949.32,  954.58
     2 |    704.61 |  701.23,  707.98
     3 |    524.65 |  521.45,  527.85
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Agency

Phase |   Slope |           95% CI |      p
-------------------------------------------
BE    |    3.62 |   -7.06,   14.31 | 0.507 
AE    |  113.19 |   93.75,  132.63 | < .001
BR    |   87.36 |   71.81,  102.90 | < .001
AR    | -289.86 | -445.20, -134.52 | < .001

Slopes are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Agency

Phase | Contrast |          95% CI |      p
-------------------------------------------
BE-AE |  -109.57 | -131.24, -87.89 | < .001
BE-BR |   -83.74 | -102.16, -65.31 | < .001
BE-AR |   293.48 |  137.60, 449.36 | < .001
AE-BR |    25.83 |   15.51,  36.15 | < .001
AE-AR |   403.04 |  241.15, 564.94 | < .001
BR-AR |   377.21 |  216.95, 537.48 | < .001

Contrasts are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Phase

Compute

Code
model <- "xFit05oPhLikes"
extra <- "1002"
terms <- c("Phase")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit05oPhLikes: [df5] LikeCount ~ Agency * Phase * Outcome + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of LikeCount

Phase | Predicted |           95% CI
------------------------------------
BE    |    681.68 |  679.79,  683.57
AE    |   1583.34 | 1580.07, 1586.61
BR    |   2354.82 | 2351.53, 2358.12
AR    |   1122.57 | 1120.33, 1124.81
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
Phase | Predicted |           95% CI |      p
---------------------------------------------
BE    |    681.68 |  679.79,  683.57 | < .001
AE    |   1583.34 | 1580.07, 1586.61 | < .001
BR    |   2354.82 | 2351.53, 2358.12 | < .001
AR    |   1122.57 | 1120.33, 1124.81 | < .001

Predictions are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# Pairwise comparisons

Phase | Contrast |             95% CI |      p
----------------------------------------------
BE-AE |  -901.66 |  -905.45,  -897.86 | < .001
BE-BR | -1673.14 | -1676.96, -1669.32 | < .001
BE-AR |  -440.88 |  -443.83,  -437.94 | < .001
AE-BR |  -771.48 |  -776.16,  -766.80 | < .001
AE-AR |   460.77 |   456.79,   464.76 | < .001
BR-AR |  1232.25 |  1228.24,  1236.27 | < .001

Contrasts are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Effects: Agency

Compute

Code
model <- "xFit05oPhLikes"
extra <- "1001"
terms <- c("Agency")

suppressWarnings(rm(list = ls(pattern = "^ggeff")))
ggeff <- get_eff_null(model, terms, extra, ofd4)
xFit05oPhLikes: [df5] LikeCount ~ Agency * Phase * Outcome + (1 | Name)
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$pred0, n = Inf)
# Average predicted counts of LikeCount

Agency | Predicted |           95% CI
-------------------------------------
    -3 |   1278.44 | 1190.46, 1366.42
    -2 |   1229.37 | 1194.91, 1263.83
    -1 |   1266.58 | 1255.01, 1278.16
     0 |   1398.78 | 1396.15, 1401.40
     1 |   1643.43 | 1641.36, 1645.50
     2 |   2031.08 | 2027.56, 2034.60
     3 |   2610.83 | 2605.81, 2615.85
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test0, n = Inf)
# (Average) Linear trend for Agency

Slope  |         95% CI |      p
--------------------------------
247.48 | 243.55, 251.40 | < .001

Slopes are presented as counts.
Code
cat0(sep0)
===================================================================== 
Code
print(ggeff$test2, n = Inf)
# (Average) Linear trend for Agency

Slope  |         95% CI |      p
--------------------------------
247.48 | 243.55, 251.40 | < .001

Slopes are presented as counts.

Plot: Basic

Code
suppressWarnings(rm(list = ls(pattern = "^gg88")))
gg88 <- ggeff$pred0 %>% plot(limit_range=FALSE, show_data = FALSE, dot_alpha = 0.05)
gg88 <- gg88 + cogsys::theme0 # + timeD + lineE + lineT + lineR + rect3 + scaleA

ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.png"), plot = gg88 + cogsys::theme2, width=8, height=24)
ggsave(file = paste0(ggeff$fbasefig, "-pred0-fig.svg"), plot = gg88 + cogsys::theme2, width=16, height=48)

gg88

Tabulate glmmTMB Models

Code
file = file.path(
  ofd4, "x-summary-tab-model-i0001-base.html")

sjPlot::tab_model(
  xFit05aPhLikes,
  xFit05oPhLikes,
  xFit06aPhRetweets,
  show.reflvl = FALSE,
  show.intercept = TRUE,
  p.style = "numeric_stars",
  show.p = FALSE,
  ## dv.labels = c("Model 1", "Model 2", "Model 3", "Model 4"),
  wrap.labels = 125,  
  file = file)
  Like Count Like Count Retweet Count
Predictors Incidence Rate Ratios CI Incidence Rate Ratios CI Incidence Rate Ratios CI
(Intercept) 47.38 *** 41.38 – 54.24 29.05 *** 23.81 – 35.45 17.28 *** 15.28 – 19.55
Agency 1.05 *** 1.04 – 1.05 0.95 *** 0.94 – 0.95 1.01 *** 1.01 – 1.02
Phase [AE] 2.16 *** 2.15 – 2.16 1.58 *** 1.58 – 1.59 1.27 *** 1.27 – 1.27
Phase [BR] 2.77 *** 2.76 – 2.77 1.57 *** 1.57 – 1.58 1.85 *** 1.85 – 1.86
Phase [AR] 1.92 *** 1.92 – 1.92 1.90 *** 1.89 – 1.91 1.40 *** 1.40 – 1.40
Agency × Phase [AE] 1.09 *** 1.09 – 1.10 1.38 *** 1.37 – 1.38 1.18 *** 1.18 – 1.19
Agency × Phase [BR] 1.42 *** 1.41 – 1.42 1.32 *** 1.31 – 1.33 1.30 *** 1.29 – 1.30
Agency × Phase [AR] 0.68 *** 0.68 – 0.68 0.58 *** 0.57 – 0.58 0.69 *** 0.69 – 0.69
Outcome [winner] 2.56 *** 1.97 – 3.32
Agency × Outcome [winner] 1.17 *** 1.16 – 1.17
Phase [AE] × Outcome [winner] 1.49 *** 1.48 – 1.49
Phase [BR] × Outcome [winner] 1.99 *** 1.99 – 2.00
Phase [AR] × Outcome [winner] 1.04 *** 1.04 – 1.04
(Agency × Phase [AE]) × Outcome [winner] 0.75 *** 0.74 – 0.75
(Agency × Phase [BR]) × Outcome [winner] 1.01 ** 1.00 – 1.01
(Agency × Phase [AR]) × Outcome [winner] 1.19 *** 1.19 – 1.20
Zero-Inflated Model
(Intercept) 0.05 *** 0.04 – 0.06 0.08 *** 0.07 – 0.09 0.08 *** 0.07 – 0.09
Agency 0.50 *** 0.40 – 0.64 0.53 *** 0.40 – 0.72 0.61 *** 0.50 – 0.73
Phase [AE] 1.02 0.85 – 1.23 1.56 *** 1.26 – 1.93 1.33 *** 1.16 – 1.54
Phase [BR] 0.77 ** 0.64 – 0.92 1.13 0.91 – 1.40 1.14 0.99 – 1.32
Phase [AR] 0.69 *** 0.57 – 0.85 1.22 0.96 – 1.54 0.98 0.84 – 1.15
Agency × Phase [AE] 0.66 * 0.47 – 0.93 0.98 0.65 – 1.47 0.49 *** 0.37 – 0.63
Agency × Phase [BR] 0.78 0.56 – 1.10 1.27 0.85 – 1.90 0.67 ** 0.52 – 0.87
Agency × Phase [AR] 0.65 * 0.45 – 0.95 1.10 0.70 – 1.74 0.58 *** 0.44 – 0.77
Outcome [winner] 0.33 *** 0.25 – 0.44
Agency × Outcome [winner] 1.07 0.64 – 1.78
Phase [AE] × Outcome [winner] 0.40 *** 0.26 – 0.61
Phase [BR] × Outcome [winner] 0.25 *** 0.15 – 0.41
Phase [AR] × Outcome [winner] 0.28 *** 0.17 – 0.45
(Agency × Phase [AE]) × Outcome [winner] 0.84 0.39 – 1.79
(Agency × Phase [BR]) × Outcome [winner] 0.69 0.29 – 1.65
(Agency × Phase [AR]) × Outcome [winner] 1.17 0.50 – 2.76
Random Effects
σ2 0.00 0.00 0.00
τ00 3.97 Name 3.61 Name 3.23 Name
ICC 1.00 1.00 1.00
N 845 Name 845 Name 845 Name
Observations 60000 60000 60000
Marginal R2 / Conditional R2 0.048 / 1.000 0.132 / 1.000 0.026 / 1.000
* p<0.05   ** p<0.01   *** p<0.001
Code
cat0(file)
./data/20240428T200156-politicians-aux-analysis/n0001-init//n0001-models-phase-i0021-all/x-summary-tab-model-i0001-base.html 
Code
save.image(file=file.path(ofd4, "session4.RData"))
## load(file.path(ofd4, "session4.RData"))

Model xFit21aPhOutcome

Fit

Code
model <- "xFit21aPhOutcome"
suppressWarnings(rm(list = model))
assign(
  model,
  glmmTMB::glmmTMB(
    formula = Outcome ~ Agency  + (1 | Name),
    family = binomial(link = "logit"),
    data = df2 %>% 
      filter(Phase=="BE") %>% 
      ## slice_sample(n=2e6) %>% 
      mutate(Outcome=as.integer(Outcome)-1) %>%
      identity()
  ))

fbase <- get_model_info(model, ofd4)
xFit21aPhOutcome: [%>%]  [df2 %>% filter(Phase == "BE") %>% mutate(Outcome = as.integer(Outcome) - 1)]  [identity()] Outcome ~ Agency + (1 | Name)
 Family: binomial  ( logit )
Formula:          Outcome ~ Agency + (1 | Name)
Data: df2 %>% filter(Phase == "BE") %>% mutate(Outcome = as.integer(Outcome) -  
    1) %>% identity()

     AIC      BIC   logLik deviance df.resid 
  1346.4   1378.2   -670.2   1340.4   304617 

Random effects:

Conditional model:
 Groups Name        Variance Std.Dev.
 Name   (Intercept) 13586    116.6   
Number of obs: 304620, groups:  Name, 850

Conditional model:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  18.8140     0.7048  26.693   <2e-16 ***
Agency        0.1325     0.8099   0.164     0.87    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------------------------------- 
xFit21aPhOutcome: [%>%]  [df2 %>% filter(Phase == "BE") %>% mutate(Outcome = as.integer(Outcome) - 1)]  [identity()] Outcome ~ Agency + (1 | Name)
# R2 for Mixed Models

  Conditional R2: 1.000
     Marginal R2: 0.000
--------------------------------------------------------------------- 
xFit21aPhOutcome: [%>%]  [df2 %>% filter(Phase == "BE") %>% mutate(Outcome = as.integer(Outcome) - 1)]  [identity()] Outcome ~ Agency + (1 | Name)
# Intraclass Correlation Coefficient

    Adjusted ICC: 1.000
  Unadjusted ICC: 1.000
--------------------------------------------------------------------- 
xFit21aPhOutcome: [%>%]  [df2 %>% filter(Phase == "BE") %>% mutate(Outcome = as.integer(Outcome) - 1)]  [identity()] Outcome ~ Agency + (1 | Name)
# ICC by Group

Group |   ICC
-------------
Name  | 1.000
--------------------------------------------------------------------- 

Reload Session/Workspace

Code
save.image(file=file.path(ofd4, "session5.RData"))
## load(file.path(ofd4, "session5.RData"))

List important variables

Code
cat0(sep0)
===================================================================== 
Code
for (var0 in ls(pattern = "(^df.*)|(^data.*)")) {cat0(var0)}
df0 
df2 
df3 
df5 
df8 
Code
cat0(sep0)
===================================================================== 
Code
for (var0 in ls(pattern = "(^fit.*)|(^xFit.*)")) {cat0(var0)}
fit01aPh 
fit02aPh 
fit03aPh 
fit04aPh 
fit04xPh 
xFit05aPhLikes 
xFit05oPhLikes 
xFit06aPhRetweets 
xFit21aPhOutcome 

Testing

Code
## save.image(file=file.path(ofd4, "session9.RData"))
Code
## test_pred0 <- readr::read_rds(file=file.path(ofd4, "fit02aPh-xtr-1001-ggeff-Time-pred0.rds"))
## test_pred0x <- ggeff$pred0
## plot(test_pred0)